Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Security > I want to save ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 1694 of 1792
Post > Topic >>

I want to save a Key in Mysql as String

by iszekeell@[EMAIL PROTECTED] May 2, 2007 at 12:55 PM

ok
so I'm trying to store a key for late for later use with a password
and i can get as far as saving and retrieving it. but can't use it
again
this is what i have:

KeyGenerator kg = KeyGenerator.getInstance("DES");
Key key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES");

cipher.init(Cipher.ENCRYPT_MODE,key);
byte[] encrypted_password = cipher.doFinal(password.getBytes());
JOptionPane.showMessageDialog(null,"Encrypted Password "+ new
String(encrypted_password));

String coughtPassword = new String(encrypted_password);

cipher.init(Cipher.WRAP_MODE,key);
byte[] keyAsByte = cipher.wrap(key);
String keyAsString = new String(keyAsByte);

//coughtpassword and keyAsString are save in mySql by a Dao

// the piece i have been unable to do is here i want to reconstruct
keyAsString into the workable key2
//any suggestions are welcome

cipher.init(Cipher.DECRYPT_MODE,key2);
byte[] decrypted_password2 =
cipher.doFinal(coughtPassword.getBytes());
JOptionPane.showMessageDialog(null,"Decrypted Password "+new
String(decrypted_password2));
 




 8 Posts in Topic:
I want to save a Key in Mysql as String
iszekeell@[EMAIL PROTECTE  2007-05-02 12:55:00 
Re: I want to save a Key in Mysql as String
"x x" <x@[EM  2007-05-04 01:26:03 
Re: I want to save a Key in Mysql as String
Mike Amling <nospam@[E  2007-05-04 16:32:59 
Re: I want to save a Key in Mysql as String
iszekeell@[EMAIL PROTECTE  2007-05-09 10:55:14 
Re: I want to save a Key in Mysql as String
Mike Amling <nospam@[E  2007-05-10 13:32:34 
Re: I want to save a Key in Mysql as String
Mike Amling <nospam@[E  2007-05-10 18:05:03 
Re: I want to save a Key in Mysql as String
iszekeell@[EMAIL PROTECTE  2007-05-10 12:58:31 
Re: I want to save a Key in Mysql as String
iszekeell@[EMAIL PROTECTE  2007-05-10 13:06:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 17:44:42 CDT 2008.