Documentation
    Preparing search index...

    The encryption class allows encrypting and decrypting values using aes-256-cbc or aes-128-cbc algorithms. The encrypted value uses a unique iv for every encryption and this ensures semantic security (read more https://en.wikipedia.org/wiki/Semantic_security).

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    verifier: MessageVerifier

    Reference to the instance of message verifier for signing and verifying values.

    base64: Base64 = base64

    Reference to base64 object for base64 encoding/decoding values

    Accessors

    • get algorithm(): "aes-256-cbc"

      The algorithm in use

      Returns "aes-256-cbc"

      The encryption algorithm being used

    Methods

    • Encrypt a given piece of value using the app secret. A wide range of data types are supported.

      • String
      • Arrays
      • Objects
      • Booleans
      • Numbers
      • Dates

      You can optionally define a purpose for which the value was encrypted and mentioning a different purpose/no purpose during decrypt will fail.

      Parameters

      • payload: any

        The data to be encrypted

      • OptionalexpiresIn: string | number

        Optional expiration time

      • Optionalpurpose: string

        Optional purpose for which the value is encrypted

      Returns string

      The encrypted payload as a string

    • Decrypt value and verify it against a purpose

      Type Parameters

      • T extends unknown

      Parameters

      • value: unknown

        The encrypted value to decrypt

      • Optionalpurpose: string

        Optional purpose that the value was encrypted for

      Returns null | T

      The decrypted data if valid, null if decryption fails