I’ve been dealing with some java application that connect to multiple databases. All the database information are stored in properties file. This includes the password as well. I stumbled upon the Cryptix.
I’m able to encrypt and decrypt using several lines of code as follow:
byte[] bytes = passwordString.getBytes(i);
Security.addProvider(new Cryptix());
RawSecretKey key = null;
key = new RawSecretKey("Blowfish","Holly's secret key to unlock".getBytes());
Cipher cipher = Cipher.getInstance("Blowfish", "Cryptix");
cipher = Cipher.getInstance(cipher, null , new PKCS7());
cipher.initDecrypt(key);
System.out.println(new String(cipher.crypt(bytes)));
To learn more about Cryptix, you can read this FAQ.
JAVA: Encrypt Your Password
May 18th, 2009
View Comments


