encrypt/decrypt text
Posted: Sat Apr 09, 2016 1:14 am
Hey Guys,
Been doing a lot of reading on the subject and getting my head in a twist. I've wrote the following two functions which encrypt and decrypt text that will go into a database or be retrieved and displayed from a database. I'm experimenting with the AES cipher as I understand not all ciphers in LC work on each platform. I also understand that when I encrypt text, it returns a binary value which could get corrupted when inserted in my database. I therefore need to encode to a hex value and store this. Logic suggests that to retrieve the value back form the database I just need to do the reverse what I did to encrypt to decrypt the hash or are the functions I've written below a one way hash only?
If I'm using H* as the formatsList to binary decode to hex, should I be using B* to binary encode back to binary?
Many thanks
Jalz
function encrypt_text tData
encrypt tData using "aes-128-cbc" with key "FFFFFFFFFFFFDDCC" at 128 bit
get binarydecode("H*",it,eData)
return eData
end encrypt_text
function decrypt_text tData
put binaryencode("B*",tData) into eData
decrypt eData using "aes-128-cbc" with key "FFFFFFFFFFFFDDCC" at 128 bit
return eData
end decrypt_text
Been doing a lot of reading on the subject and getting my head in a twist. I've wrote the following two functions which encrypt and decrypt text that will go into a database or be retrieved and displayed from a database. I'm experimenting with the AES cipher as I understand not all ciphers in LC work on each platform. I also understand that when I encrypt text, it returns a binary value which could get corrupted when inserted in my database. I therefore need to encode to a hex value and store this. Logic suggests that to retrieve the value back form the database I just need to do the reverse what I did to encrypt to decrypt the hash or are the functions I've written below a one way hash only?
If I'm using H* as the formatsList to binary decode to hex, should I be using B* to binary encode back to binary?
Many thanks
Jalz
function encrypt_text tData
encrypt tData using "aes-128-cbc" with key "FFFFFFFFFFFFDDCC" at 128 bit
get binarydecode("H*",it,eData)
return eData
end encrypt_text
function decrypt_text tData
put binaryencode("B*",tData) into eData
decrypt eData using "aes-128-cbc" with key "FFFFFFFFFFFFDDCC" at 128 bit
return eData
end decrypt_text