Encrypt data
Hi,
I am wanting to check if there is any built-in mechanism in Titanium to encrypt data. This is to encrypt customer's sensitive information and send it across to a web service. I have both triple DES & Rijndael algorithm implemented on the server side.
Please help.
Thanks,
2 Answers
-
fwiw, we have used the google aes code from here
https://code.google.com/p/crypto-js/downloads/detail?name=CryptoJS%20v3.0.2.zip&can=2&q=
and then unzipped and included the file under rollups/aes.js
You can use it like this …var encrypt = function(message){ var encrypted = CryptoJS.AES.encrypt(message, "Secret Passphrase"); var obj = {}; obj.iv = encrypted.iv.toString(); obj.s = encrypted.salt.toString(); obj.ct = encrypted.ciphertext.toString(CryptoJS.enc.Base64); return obj; } var decrypt = function(obj){ var cipherParams = CryptoJS.lib.CipherParams.create({ ciphertext: CryptoJS.enc.Base64.parse(obj.ct) }); cipherParams.salt = CryptoJS.enc.Hex.parse(obj.s); cipherParams.iv= CryptoJS.enc.Hex.parse(obj.iv); var message =CryptoJS.AES.decrypt( cipherParams , "Secret Passphrase").toString(CryptoJS.enc.Utf8); return message; }
-
You can do this using some js implementations.