Decoding encrypted data
Author: cdouglass@siriussoftware.com.au (Colin)
Hi,
I am having problems decoding data that has been encoded using the uniface proc code $encode.
I am trying to use a secure format like "AES" using "CBC" as is described in the uniface documentation, but I keep getting an error when trying to read the data back and decode it. $procerrorcontext="ERROR=-1791;MNEM=<UENCERR_GENERAL>;DESCRIPTION=Encode/decode general error;COMPONENT=CDMNTDEB;PROCNAME=21\\DECR;TRIGGER=DECR;LINE=2;ADDITIONAL=StreamTransformationFilter: ciphertext length is not a multiple of block size"
The documentation has this
; Create an initialization vector.
vIv = $datim
; Encrypt the source data by AES in CBC mode.
vEnc = $encode("AES", vSource, vKey, "CBC", vIv)
; Decrypt the encrypted data.
; DECRYPT must be the same as SOURCE.
vDecrypt = $decode("AES", vEnc, vKey, "CBC", vIv)
I have this code in the encrypt trigger which encodes the data (apparently correctly because the result in the database is the encrypted string)
variables
string v_enc
endvariables
v_enc = $encode("AES", @$fieldname, "creditcardnumber", "CBC", $datim)
card_no.cd_debtor/init = v_enc
I have this code in the decrypt trigger that gives the above error
variables
string v_enc
endvariables
v_enc = $decode("AES", @$fieldname, "creditcardnumber", "CBC", $datim)
card_no.debtor/init = v_enc
?
I have tried for a while but I am getting nowhere. I can get it to properly encrypt and decrypt if I use BASE64 but I would rather use something a little more secure.
Thanks in advance
Colin Douglass




