Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lib/support/crypto"

Index

Variables

Const algo

algo: "aes-256-cbc" = "aes-256-cbc"

Const algoIvLength

algoIvLength: 16 = 16

Const algoKeyLength

algoKeyLength: 32 = 32

Functions

decrypt

  • decrypt(text: string, key: string): Promise<string>
  • Decrypt a base64 encoded text string.

    Parameters

    • text: string

      Base64 encoded string to be decrypted

    • key: string

      Secrey key/passphrase to use to decrypt, must be the same as the one used to encrypt

    Returns Promise<string>

    UTF8 encoded string of decrypted text

deriveKey

  • deriveKey(key: string, length?: number): Promise<Buffer>
  • Create an encryption key of length length derived using a CPU and memory intensive algorithm. The key is used directly and hashed to generate the salt for the derivation process.

    Parameters

    • key: string

      Key used to derive encryption key

    • Default value length: number = algoKeyLength

      Length of derived key

    Returns Promise<Buffer>

    Encryption key of length length

encrypt

  • encrypt(text: string, key: string): Promise<string>
  • Encrypt a text string and return is base64 encoded. The key is used to derive a suitable key and initialization vector.

    Parameters

    • text: string

      String to be encrypted

    • key: string

      Secrey key/passphrase to use to encrypt

    Returns Promise<string>

    Base64 encoded string of encrypted text

Generated using TypeDoc