javax.crypto and Perl module Crypt::CBC
843811Jul 5 2006 — edited Feb 1 2010Hi,
My problem is when I encrypt on the JAVA side with :
String inkey = "123456781234567812345678";
final byte[] ivBytes = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
byte[] rawkey = inkey.getBytes();
DESedeKeySpec keyspec = new DESedeKeySpec(rawkey);
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DESede");
SecretKey key = keyfactory.generateSecret(keyspec);
encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding", "SunJCE");
encryptCipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key, iv);
synchronized public String encrypt(String Entry) throws Exception {
byte[] EntryBytes = Entry.getBytes(characterEncoding);
byte[] encryptedEntryBytes = this.encryptCipher.doFinal(EntryBytes);
String encodedEncryptedEntry = this.base64Encoder.encode(encryptedEntryBytes);
return encodedEncryptedEntry;
}
and try to decrypt on the Perl side with :
$cbc_encrypt_key = "123456781234567812345678";
$cbc_iv = "12345678";
$css_cipher = Crypt::CBC->new(
-cipher => DES_EDE3,
-key => $cbc_encrypt_key,
-iv => $cbc_iv,
-header => 'none'
);
$info = decode_base64($info);
$info = $css_cipher->decrypt($info);
it doesn't work at all, Perl can't decrypt. Is there any compatibilty problem ? or is my code wrong (i suppose so)
Please help me
Ed