• Creating Symmetric Encryption Objects

    Parameters

    • algorithm: Algorithm

      Encryption algorithm. Note: AES-ECB is not a secure encryption algorithm and is not recommended.

    • key: Buffer

      Indicates the key. Note: Sensitive information must not be written in plaintext in the code.

    • option: "crypto".Option

      Encryption Options

    Returns Cipher

    Example


    import * as crypto from 'crypto';
    import * as buffer from 'buffer';

    let key = buffer.from("***********9");
    let nonce = buffer.from("********2");
    let plainText = buffer.from('****');

    let cipher = crypto.createCipher(crypto.Algorithm.AES_GCM, key, { nonce: nonce });
    let cipherText = cipher.encrypt(plainText);
    console.log(cipherText.toString(buffer.Encoding.Base64));