Hi,
Doing encryption with JBASE_CRYPT_3DES_BASE64 on JBASE, with same algorithm
i'm trying to encrypt the same String on Java,but it gives different
outputs,
Also tried to encrypt at jbase end and decrypt with java using
3DES_BASE64with same key but it throws Bad Padding Exception.
Below are my code snippets:
INCLUDE JBC.h
cipher = JBASE_CRYPT_3DES_BASE64
key = "566AB0D61A568842DBBF9F27"
str = "String to encrypt"
enc = ENCRYPT( str, key, cipher )
CRT enc
Output : */CryFPPNO4xuKIMqxLpkXKmNOgtgOZYg*
and here is the java Code:
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;
}
Output : */CryFPPNO4ygWJJwXv5P3SnBi7rMnrAh*
on checking the output the first 10 characters are same, and differs from
there.
leave your comments
--
Please read the posting guidelines at:
http://groups.google.com/group/jBASE/web/Posting%20Guidelines
IMPORTANT: Type T24: at the start of the subject line for questions specific to
Globus/T24
To post, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en