SerializableCipher: {
    _parse(ciphertext: string | cryptojs.lib.CipherParams, format: Format): cryptojs.lib.CipherParams;
    decrypt(cipher: CipherStatic, ciphertext: string | cryptojs.lib.WordArray, key: cryptojs.lib.WordArray, cfg?: CipherOption): cryptojs.lib.CipherParams;
    encrypt(cipher: CipherStatic, message: string | cryptojs.lib.WordArray, key: cryptojs.lib.WordArray, cfg?: CipherOption): cryptojs.lib.CipherParams;
}

A cipher wrapper that returns ciphertext as a serializable cipher params object.

Type declaration

  • _parse:function
    • Converts serialized ciphertext to CipherParams, else assumed CipherParams already and returns ciphertext unchanged.

      Parameters

      • ciphertext: string | cryptojs.lib.CipherParams

        The ciphertext.

      • format: Format

        The formatting strategy to use to parse serialized ciphertext.

      Returns cryptojs.lib.CipherParams

      The unserialized ciphertext.

      var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
      
  • decrypt:function
    • Decrypts serialized ciphertext.

      Parameters

      • cipher: CipherStatic

        The cipher algorithm to use.

      • ciphertext: string | cryptojs.lib.WordArray

        The ciphertext to decrypt.

      • key: cryptojs.lib.WordArray

        The key.

      • Optionalcfg: CipherOption

        (Optional) The configuration options to use for this operation.

      Returns cryptojs.lib.CipherParams

      The plaintext.

      var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
      var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  • encrypt:function
    • Encrypts a message.

      Parameters

      • cipher: CipherStatic

        The cipher algorithm to use.

      • message: string | cryptojs.lib.WordArray

        The message to encrypt.

      • key: cryptojs.lib.WordArray

        The key.

      • Optionalcfg: CipherOption

        (Optional) The configuration options to use for this operation.

      Returns cryptojs.lib.CipherParams

      A cipher params object.

      var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
      var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
      var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });