hello.
I have a code in Asp.net . it encrypts a string with TripleDes. and I use CryptoJs library but the results are not the same. here are the codes:
var dataBytes = Encoding.UTF8.GetBytes(str);
var symmetric = SymmetricAlgorithm.Create(“TripleDes”);
symmetric.Mode = CipherMode.ECB;
symmetric.Padding = PaddingMode.PKCS7;
var encryptor = symmetric.CreateEncryptor(Convert.FromBase64String(key), new byte[8]);
enc = Convert.ToBase64String(encryptor.TransformFinalBlock(dataBytes, 0, dataBytes.Length));
and its my code:
var dataBytes = CryptoJS.enc.Utf8.parse(str);
var key = CryptoJS.enc.Base64.parse(Key);
var encrypted = CryptoJS.DES.encrypt(dataBytes, key , {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
});
var enc = encrypted.ciphertext.toString(CryptoJS.enc.Base64);