Hello,
I am trying to use DBMS_OBFUSCATION_TOOLKIT to encrypt and decrypt some data.
Here is the prog for that but when I use returned data for decrypting using same key I do not get same results.
Am I missing some step.
String encryptionKey="tiger123";
String encryptedString = "";
try {
CallableStatement cstmt;
con = dataSource.getConnection();
String procedureCall = "{call dbms_obfuscation_toolkit.DES3Encrypt(INPUT_STRING =>?,KEY_STRING=>?,ENCRYPTED_STRING=>?)}";
//String procedureCall = "{call crypt_util.crypt(p_str =>?,p_key=>?)}";
cstmt = con.prepareCall(procedureCall);
cstmt.setString(1, "anand123");
cstmt.setString(2, encryptionKey);
cstmt.setString(3, encryptedString);
cstmt.registerOutParameter(3, Types.VARCHAR);
cstmt.executeUpdate();
encryptedString = cstmt.getString(3);
System.out.println("encryptedString " + encryptedString);
cstmt.close();
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch(Exception ce) {
logError(ce);
}
finally {
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Any help will be much appreciated..
Thanks,
Anand