PHP Classes

File: api5/api5/js/cryptojs-aes/aes-json-format.js

Recommend this page to a friend!
  Classes of Santo Nuzzolillo  >  API SQL to JSON  >  api5/api5/js/cryptojs-aes/aes-json-format.js  >  Download  
File: api5/api5/js/cryptojs-aes/aes-json-format.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: API SQL to JSON
Send AJAX requests and responding with JSON data
Author: By
Last change:
Date: 4 years ago
Size: 797 bytes


Class file image Download
* AES JSON formatter for CryptoJS
* @author BrainFooLong (
* @link

var CryptoJSAesJson = {
    stringify: function (cipherParams) {
        var j = {ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64)};
        if (cipherParams.iv) j.iv = cipherParams.iv.toString();
        if (cipherParams.salt) j.s = cipherParams.salt.toString();
        return JSON.stringify(j);
    parse: function (jsonStr) {
        var j = JSON.parse(jsonStr);
        var cipherParams = CryptoJS.lib.CipherParams.create({ciphertext: CryptoJS.enc.Base64.parse(j.ct)});
        if (j.iv) cipherParams.iv = CryptoJS.enc.Hex.parse(j.iv);
        if (j.s) cipherParams.salt = CryptoJS.enc.Hex.parse(j.s);
        return cipherParams;
For more information send a message to info at phpclasses dot org.