How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • decrypt(data, convert = true) {
            var params = JSON.parse(atob(data));
            var decrypted = CryptoJS.AES.decrypt(params.value, CryptoJS.enc.Base64.parse(this.key), {
                iv: CryptoJS.enc.Base64.parse(params.iv)
            }).toString(CryptoJS.enc.Utf8);
    
            return convert ? unserialize(decrypted) : decrypted;
        }
    
    /tzsk/laravel-crypton mit
  • var hash = CryptoJS.SHA256("Message");
    ​
    hash.toString(CryptoJS.enc.Base64)
    > "L3dmip37+NWEi57rSnFFypTG7ZI25Kdz9tyvpRMrL5E=";
    ​
    hash.toString(CryptoJS.enc.Hex)
    > "2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f91";
    Docs
  • var words = CryptoJS.enc.Base64.parse("SGVsbG8sIFdvcmxkIQ==");var base64 = CryptoJS.enc.Base64.stringify(words);var words = CryptoJS.enc.Latin1.parse("Hello, World!");var latin1 = CryptoJS.enc.Latin1.stringify(words);var words = CryptoJS.enc.Hex.parse("48656c6c6f2c20576f726c6421");var hex = CryptoJS.enc.Hex.stringify(words);var words = CryptoJS.enc.Utf8.parse("𔭢");var utf8 = CryptoJS.enc.Utf8.stringify(words);var words = CryptoJS.enc.Utf16.parse("Hello, World!");var utf16 = CryptoJS.enc.Utf16.stringify(words);var words = CryptoJS.enc.Utf16LE.parse("Hello, World!");var utf16 = CryptoJS.enc.Utf16LE.stringify(words);
    Docs
  • const encryptKey = (data, key) => {
      console.log('encrypting: ', data, key);
      const stampedData = getStampedData(data);
      const encJson = CryptoJS.AES.encrypt(JSON.stringify(stampedData), key).toString();
      let encData = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(encJson));
      console.log('returning: ', encData);
      return encData;
    };
    
    
    /ecency/ecency-mobile mit
  • var JsonFormatter = {
      stringify: function(cipherParams) {
        // create json object with ciphertext
        var jsonObj = { ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64) };// optionally add iv or salt
        if (cipherParams.iv) {
          jsonObj.iv = cipherParams.iv.toString();
        }if (cipherParams.salt) {
          jsonObj.s = cipherParams.salt.toString();
        }// stringify json object
        return JSON.stringify(jsonObj);
      },
      parse: function(jsonStr) {
        // parse json string
        var jsonObj = JSON.parse(jsonStr);// extract ciphertext from json object, and create cipher params object
        var cipherParams = CryptoJS.lib.CipherParams.create({
          ciphertext: CryptoJS.enc.Base64.parse(jsonObj.ct)
        });// optionally extract iv or saltif (jsonObj.iv) {
          cipherParams.iv = CryptoJS.enc.Hex.parse(jsonObj.iv);
        }if (jsonObj.s) {
          cipherParams.salt = CryptoJS.enc.Hex.parse(jsonObj.s);
        }return cipherParams;
      }
    };var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase", {
      format: JsonFormatter
    });
    ​
    encrypted
    > {
        ct: "tZ4MsEnfbcDOwqau68aOrQ==",
        iv: "8a8c8fd8fe33743d3638737ea4a00698",
        s: "ba06373c8f57179c"
      };var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase", {
      format: JsonFormatter
    });
    ​
    decrypted.toString(CryptoJS.enc.Utf8)
    > "Message";
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples