Enter your full question here
<p><b>
i have been experimenting with the JCE package and have been successful in encrypting and decrypting data in a single session.
I have the following question : using JCE, how can I encrypt data with the same key so that it can be decrypted at a later date? I assume that a key can be stored and used to encrypt / decrypt data as needed.
The practical application for this is in the need to store demographic information (possibly financial info) about users in an Oracle database. I would need to encrypt it before storing it and then decrypt it as needed.
my code is
public
String decryptpasswd(String username){
String query="select cust_passwd from mxi_customer where cust_uid='"+username+"'";
String s="";
try{
KeyGenerator keygen = KeyGenerator.getInstance("DES");
SecretKey desKey = keygen.generateKey();
Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
// Initialize the cipher for encryption
desCipher.init(Cipher.DECRYPT_MODE, desKey);
// Decrypt the ciphertext
DbBean myDb=new DbBean();
myDb.connect();
ResultSet Rs= myDb.execSQL(query);
if (Rs.next()) {
String passwd=Rs.getString("cust_passwd");
byte[] passwd1=passwd.getBytes();
byte[] cleartext = desCipher.doFinal(passwd1);
s=new String(cleartext);
}
}
catch(Exception e){return e.toString();}return s;
i got Exception
like this
javax.crypto.IllegalBlockSizeException: Input length (with padding) not multiple of 8 bytes
any body know help me
venkat
</b></p>
Please use html tags to format code blocks.