Represents encryption operation

Example

// Encrypt multi-part data

const alg = {
name: "AES_CBC_PAD",
params: session.generateRandom(16), // IV
};
const cipher = session.createCipher(alg, secretKey);
let enc = cipher.update("Some message");
enc = Buffer.concat([enc, cipher.final()]);
console.log(enc.toString("hex")); // 351a253df0d5bc9018afd7eed825ae9a

Example

// Encrypt single-part data

const alg = {
name: "AES_CBC_PAD",
params: session.generateRandom(16), // IV
};
const enc = session.createCipher(alg, secretKey)
.once("Some data", Buffer.alloc(1024));
console.log(enc.toString("hex")); // 0a3335e0ec8b0265d6ca70d789649b94

Hierarchy (view full)

Constructors

Properties

Methods

Constructors

Properties

lib: PKCS11

PKCS#11 module

session: Session

Session

Methods

  • Finishes a multiple-part encryption operation

    Returns Buffer

    The final encrypted block

  • Encrypts single-part data

    Parameters

    • data: CryptoData

      Data to be encrypted

    • enc: Buffer

      Allocated buffer for encrypted data

    Returns Buffer

  • Encrypts single-part data

    Parameters

    • data: CryptoData

      Data to be encrypted

    • enc: Buffer

      Allocated buffer for encrypted data

    • cb: ((error, data) => void)

      Async callback function with encrypted data

        • (error, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • Continues a multiple-part encryption operation

    Parameters

    • data: CryptoData

      Data to be encrypted

    Returns Buffer

    Encrypted block

Generated using TypeDoc