Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Encrypt data


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.


— asked September 15th 2010 by Sravan Vinjamuri
  • data
  • encrypt
  • iphone

2 Answers

  • fwiw, we have used the google aes code from here


    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;
    — answered August 23rd 2012 by nigel taylor
    • I cannot decrypt with this code. Encrypt is OK, I can access all parts of the encrypt object but there's no way I can use the decrypt function. Too bad…

      — commented November 27th 2013 by michel perrin
    • Did you get a solution for this?

      — commented April 28th 2014 by Martin Johansson
  • You can do this using some js implementations.

    — answered September 15th 2010 by Dan Tamas
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.