Hi,
I am trying to implement the encryption-decryption with TDES algorithm. Below is the piece of code I have written:
//Instance Variables
CONSTANT STRING ICS_KEY = "pP?g$L#C%a)*N^A*dX&Ao1j4"
CONSTANT STRING ICS_IV = "?Im#9-0$"
//Encryption function:
Blob lb_data, lb_key, lb_iv, lb_encrypt
String ls_input, ls_encrypt
ls_input = "ENCRYPT_THIS"
lb_data = Blob(ls_input, EncodingUTF8!)
lb_key = Blob(ICS_KEY, EncodingUTF8!)
lb_iv = Blob(ICS_IV, EncodingUTF8!)
CrypterObject lnv_CrypterObject
lnv_CrypterObject = Create CrypterObject
lb_encrypt = lnv_CrypterObject.SymmetricEncrypt(TDES!, lb_data, lb_key, OperationModeCBC!, lb_iv, PKCSPadding!)
ls_encrypt = String(lb_encrypt, EncodingUTF8!)
st_encrypted.Text = ls_encrypt
-----------------------------------------------------------------------------------------------------------------------------------
//Decryption function:
Blob lb_data, lb_key, lb_iv, lb_decrypt
String ls_input, ls_decrypt
ls_input = st_encrypted.Text
lb_data = Blob(ls_input, EncodingUTF8!)
lb_key = Blob(ICS_KEY, EncodingUTF8!)
lb_iv = Blob(ICS_IV, EncodingUTF8!)
CrypterObject lnv_CrypterObject
lnv_CrypterObject = Create CrypterObject
lb_decrypt = lnv_CrypterObject.SymmetricDecrypt(TDES!, lb_data, lb_key, OperationModeCBC!, lb_iv, PKCSPadding!)
ls_decrypt = String(lb_decrypt, EncodingUTF8!)
st_decrypted.Text = ls_decrypt
It is supposed to give me the original input string "ENCRYPT_THIS" after decryption, but it is not. The encrypted string and the decrypted string gives me random values. It works completely fine when I use encoding format as EncodingANSI!. Can someone help on this?
--Thanks.
--Thanks.