PasswordBasedCipher: {
    decrypt(cipher: CipherStatic, ciphertext: string | cryptojs.lib.CipherParams, password: string, cfg?: CipherOption): cryptojs.lib.WordArray;
    encrypt(cipher: CipherStatic, message: string | cryptojs.lib.WordArray, password: string, cfg?: CipherOption): cryptojs.lib.CipherParams;
}

A serializable cipher wrapper that derives the key from a password, and returns ciphertext as a serializable cipher params object.

Type declaration

  • decrypt:function
    • Decrypts serialized ciphertext using a password.

      Parameters

      • cipher: CipherStatic

        The cipher algorithm to use.

      • ciphertext: string | cryptojs.lib.CipherParams

        The ciphertext to decrypt.

      • password: string

        The password.

      • Optionalcfg: CipherOption

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

      Returns cryptojs.lib.WordArray

      The plaintext.

      var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
      var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  • encrypt:function
    • Encrypts a message using a password.

      Parameters

      • cipher: CipherStatic

        The cipher algorithm to use.

      • message: string | cryptojs.lib.WordArray

        The message to encrypt.

      • password: string

        The password.

      • Optionalcfg: CipherOption

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

      Returns cryptojs.lib.CipherParams

      A cipher params object.

      var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
      var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });