Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Always generating same key pairs..even on using random intializtion

843811Mar 4 2006 — edited Mar 10 2006
hi,
i am using public key encryption. i used the below code to generate key pairs. the created keys are stored in database as Blob format. inspite of using the random intializtion in key generation the generated key are same (having same hexadecimal code in the database). How can i generate different pairs of keys
/*Code used for key pair generation*/
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
           SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
		 Random rand = new Random();
		 int seed = rand.nextInt(10000000);
		random.setSeed(seed);
		byte bytes[] = new byte[20];
		random.nextBytes(bytes);
     
		keyGen.initialize(1024,random);
        KeyPair key = keyGen.generateKeyPair();
thnx
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 7 2006
Added on Mar 4 2006
7 comments
767 views