Module ngx-oauth.crypto

Cryptographic utilities.

Functions

encrypt (bits, key, value) Encrypts the given string using AES.
decrypt (bits, key, value) Decrypts the given value using AES.


Functions

encrypt (bits, key, value)
Encrypts the given string using AES.

Parameters:

  • bits int The AES block size in bits: 128, 192, or 256.
  • key string The secret key to use for encryption. It must be greater or equal than bits / 8.
  • value string The string to encrypt.

Returns:

    string A pair of IV and encrypted string encoded in Base64.

Raises:

If the specified key length (bits) is not supported or the key is too short.
decrypt (bits, key, value)
Decrypts the given value using AES.

Parameters:

  • bits int The AES block size in bits: 128, 192, or 256.
  • key string The secret key to use for decryption. It must be greater or equal than bits / 8.
  • value string The pair of IV and encrypted string encoded in Base64.

Returns:

    string or nil A decrypted string, or nil if the value is malformed or cannot be decrypted with the given key.

Raises:

If the specified key length (bits) is not supported or the key is too short.
generated by LDoc 1.4.3