dcsimg
3DES key generation
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ilana_mush
Posted On:   Thursday, August 1, 2002 01:39 AM

Hello, I want to write code that encrypts a string. Part of the process is to generate a key. I found the following way to do that: KeyGenerator key_gen = KeyGenerator.getInstance(algorithm, provider); Key m_des_key = key_gen.generateKey(); My question is: Is there a way to create a key that is not random, e.g I will give a string representing a key and the key generator will create a 3DES key for me, Something like that maybe: KeyGenerator key_gen = KeyGenerator.getInstance(algorithm, provider, key); p.s. I'm using the SunJCE implementation. Thanks in advance, Ilana    More>>

Hello,

I want to write code that encrypts a string.
Part of the process is to generate a key.
I found the following way to do that:


KeyGenerator key_gen = KeyGenerator.getInstance(algorithm, provider);

Key m_des_key = key_gen.generateKey();



My question is:

Is there a way to create a key that is not random, e.g I will give a string representing a key and the key generator will create a 3DES key for me,

Something like that maybe:


KeyGenerator key_gen = KeyGenerator.getInstance(algorithm, provider, key);


p.s. I'm using the SunJCE implementation.



Thanks in advance,

Ilana

   <<Less

Re: 3DES key generation

Posted By:   Zac_Jacobson  
Posted On:   Tuesday, August 13, 2002 10:41 AM

Here is one way to do it:

KeyGenerator generator = KeyGenerator.getInstance( "DESede" );
SecureRandom random = SecureRandom.getInstance( "SHA1PRNG" );
random.setSeed( );
generator.init( random );
SecretKey myKey = generator.generateKey( );
About | Sitemap | Contact