INCLUDE JBC.h
cipher = JBASE_CRYPT_3DES_BASE64
key = "566AB0D61A568842DBBF9F27"
str = "String to encrypt"
enc = ENCRYPT( str, key, cipher )
CRT enc
Output : /CryFPPNO4xuKIMqxLpkXKmNOgtgOZYg
public DESedeEncryption() throws Exception
{
myEncryptionKey = "566AB0D61A568842DBBF9F27";
myEncryptionScheme = DESEDE_ENCRYPTION_SCHEME;
keyAsBytes = myEncryptionKey.getBytes(UNICODE_FORMAT);
myKeySpec = new DESedeKeySpec(keyAsBytes);
mySecretKeyFactory = SecretKeyFactory.getInstance(myEncryptionScheme);
cipher = Cipher.getInstance(myEncryptionScheme);
key = mySecretKeyFactory.generateSecret(myKeySpec);
}
/**
* Method To Encrypt The String
*/
public String encrypt(String unencryptedString) {
String encryptedString = null;
try {
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] plainText = unencryptedString.getBytes(UNICODE_FORMAT);
byte[] encryptedText = cipher.doFinal(plainText);
BASE64Encoder base64encoder = new BASE64Encoder();
encryptedString = base64encoder.encode(encryptedText);
} catch (Exception e) {
e.printStackTrace();
}
return encryptedString;
}