Random Key Generation Algorithm In Java

  

Key generators are constructed using one of the getInstance class methods of this class. KeyGenerator objects are reusable, i.e., after a key has been generated, the same KeyGenerator object can be re-used to generate further keys. There are two ways to generate a key: in an algorithm-independent manner. Java Cryptography - KeyGenerator - Java provides KeyGenerator class this class is used to generate secret keys and objects of this class are reusable. Dec 14, 2011 Random Number Generation in Java:-Java provides mainly two sets of API/classes to generate Random numbers: Random and SecureRandom. Random API: This is used to generate a stream of pseudorandom numbers. It uses a 48-bit seed (the initial data) which is then modified using a linear congruential formula. On this github page there is utility class written in Java which performs encryption/decryption using symmetric algorithm, below could be one of encryption flows using symmetric algorithm: generate secret key using the selected algorithm (DES, 3DES, AES etc).

Ranch Hand
posted 19 years ago
Hi!
Well I need a pseudo Random Number Generation algorithm which makes the numbers repeat after a certain userdefined period.
Please some one help me with the same asap since I need it very badly and soon.
Tanx for all the help.
Regds
Gautham Kasinath
P.S. Sheriffs and Bartenders please forgive my posting the message here since I didnot now where to post the same.

'In the country of the blind, the one eyed man is the King'
Gautham Kasinath CV at : http://www.geocities.com/gkasinath

Ranch Hand
posted 19 years agoWhy don't you just use Random()Data structure and algorithm in java, and store the results in an ArrayList? You could iterate through a loop a user-specified number of times, filling the ArrayList with Random.next(), and then the values would be accessible in any order out of the ArrayList.
------------------
Random key generation algorithm
  • Ryan Burgdorfer
  • Java Acolyte in
  • Columbus, OH USA

/cisco-asa-ssh-crypto-key-generate.html. <UL TYPE=SQUARE><I><LI>Ryan Burgdorfer<BR><LI>Java Acolyte</I></UL>

Ranch Hand
posted 19 years ago
Hi!
Well I guess that would will lower the performance of what i m coding.
What I was looking for is a ready made algorithm that generates pseudo random numbers. the numbers are bound to repeat sequence over a period of time.
Regds
Gautham Kasinath

'In the country of the blind, the one eyed man is the King'
Gautham Kasinath CV at : http://www.geocities.com/gkasinath

author
posted 19 years ago
You could try the colt library. It's proported to be rather speedy and I believe the source is included as well.
http://tilde-hoschek.home.cern.ch/~hoschek/colt/index.htm
Though, the java random() function may be the cleaner solution.
Sean

Free Java Algorithms

Sheriff
posted 19 years ago
Why not just use a cipher algorithm like RC4? If speed is an issue, you could probably scale it down (although it's pretty fast to being with). It would make it less 'secure' but it doesn't sound like you need a crypto-strength PRNG.
--Mark
hershey@vaultus.com
Wanderer

Random Key Generation Algorithm In Java 10

posted 19 years ago
You can make any algorithm repeat by wrapping it in a class which counts how many random numbers have been generated,and resets everything once it's time to repeat. You don't need to save all the generated numbers in a list as Ryan suggested; it is sufficient to remember the seed which started the sequence. Here's an example built around java.util.Random; you can use any other seedable random number generator instead if you wish.
<code><pre>
import java.util.Random;
class CyclicRandom {
private Random random;
private long seed;
private int period;
private int count;
public CyclicRandom(long seed, int period) {
random = new Random(seed);
this.seed = seed;
this.period = period;
}
public long nextLong() {
next();
return random.nextLong();
}
public double nextDouble() {
next();
return random.nextDouble();
}
private void next() {
count++;
if (count > period) {
random.setSeed(seed);
count = 0;
}
}
}
</code></pre>
[This message has been edited by Jim Yingst (edited March 29, 2001).]