decrypt(encryptedString, key) {
    var json = JSON.parse(
      CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(encryptedString))
    );

    var salt = CryptoJS.enc.Hex.parse(json.salt);
    var iv = CryptoJS.enc.Hex.parse(json.iv);

    var encrypted = json.ciphertext; // no need to base64 decode.

    var iterations = parseInt(json.iterations);
    if (iterations <= 0) {
      iterations = 999;
    }
    var encryptMethodLength = this.encryptMethodLength / 4; // example: AES number is 256 / 4 = 64
    var hashKey = CryptoJS.PBKDF2(key, salt, {
      hasher: CryptoJS.algo.SHA512,
      keySize: encryptMethodLength / 8,
      iterations: iterations
    });

    var decrypted = CryptoJS.AES.decrypt(encrypted, hashKey, {
      mode: CryptoJS.mode.CBC,
      iv: iv
    });

    return decrypted.toString(CryptoJS.enc.Utf8);
  } // decrypt
/**
   * Decrypt string.
   * @param string encryptedString The encrypted string to be decrypt.
   * @param string key The key.
   * @return string Return decrypted string.
   */
Decrypt string.
@param string encryptedString The encrypted string to be decrypt.
@param string key The key.
@return string Return decrypted string.
Decrypt string . @param string encryptedString The encrypted string to be decrypt . @param string key The key . @return string Return decrypted string .
decrypt(encryptedString, key) {
    var json = JSON.parse(
      CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(encryptedString))
    );
    var salt = CryptoJS.enc.Hex.parse(json.salt);
    var iv = CryptoJS.enc.Hex.parse(json.iv);
    var encrypted = json.ciphertext; 
    var iterations = parseInt(json.iterations);
    if (iterations <= 0) {
      iterations = 999;
    }
    var encryptMethodLength = this.encryptMethodLength / 4; 
    var hashKey = CryptoJS.PBKDF2(key, salt, {
      hasher: CryptoJS.algo.SHA512,
      keySize: encryptMethodLength / 8,
      iterations: iterations
    });
    var decrypted = CryptoJS.AES.decrypt(encrypted, hashKey, {
      mode: CryptoJS.mode.CBC,
      iv: iv
    });
    return decrypted.toString(CryptoJS.enc.Utf8);
  } 
decrypt ( encryptedString , key ) { var json = JSON . parse ( CryptoJS . enc . Utf8 . stringify ( CryptoJS . enc . Base64 . parse ( encryptedString ) ) ) ; var salt = CryptoJS . enc . Hex . parse ( json . salt ) ; var iv = CryptoJS . enc . Hex . parse ( json . iv ) ; var encrypted = json . ciphertext ; var iterations = parseInt ( json . iterations ) ; if ( iterations <= 0 ) { iterations = 999 ; } var encryptMethodLength = this . encryptMethodLength / 4 ; var hashKey = CryptoJS . PBKDF2 ( key , salt , { hasher : CryptoJS . algo . SHA512 , keySize : encryptMethodLength / 8 , iterations : iterations } ) ; var decrypted = CryptoJS . AES . decrypt ( encrypted , hashKey , { mode : CryptoJS . mode . CBC , iv : iv } ) ; return decrypted . toString ( CryptoJS . enc . Utf8 ) ; }
Decrypt string.
Decrypt string .
// no need to base64 decode. // example: AES number is 256 / 4 = 64 // decrypt