Potassium API
  • Environment
    • Cache
    • Closures
    • Console
    • Crypt
    • Debug
    • Drawing
    • File System
    • Input
    • Instance
    • Metatable
    • Miscellaneous
    • Scripts
    • Web Sockets
    • Actor
Powered by GitBook
On this page
  • crypt.base64encode
  • crypt.base64decode
  • crypt.encrypt
  • crypt.decrypt
  • crypt.generatebytes
  • crypt.generatekey
  • crypt.hash
  1. Environment

Crypt

crypt.base64encode

<string> crypt.base64encode(<string> data)

Encodes a string of bytes into Base64.


crypt.base64decode

<string> crypt.base64decode(<string> data)

Decodes a Base64 string to a string of bytes.


crypt.encrypt

<string, string> crypt.encrypt(<string> data, <string> key, <string?> iv, <string?> mode)

Encrypts an unencoded string using AES encryption. Returns the base64 encoded and encrypted string, and the IV.

If an AES IV is not provided, a random one will be generated for you, and returned as a 2nd base64 encoded string.

The cipher modes are 'CBC', 'ECB', 'CTR', 'CFB', 'OFB', and 'GCM'. The default is 'CBC'.


crypt.decrypt

<string> crypt.encrypt(<string> data, <string> key, <string> iv, <string> mode)

Decrypts the base64 encoded and encrypted content. Returns the raw string.

The cipher modes are 'CBC', 'ECB', 'CTR', 'CFB', 'OFB', and 'GCM'.


crypt.generatebytes

<string> crypt.generatebytes(<number> size)

Generates a random sequence of bytes of the given size. Returns the sequence as a base64 encoded string.


crypt.generatekey

<string> crypt.generatekey()

Generates a base64 encoded 256-bit key. The result can be used as the second parameter for the crypt.encrypt and crypt.decrypt functions.


crypt.hash

<string> crypt.hash(<string> data, <string> algo)

Returns the result of hashing the data using the given algorithm.

Some algorithms include 'sha1', 'sha384', 'sha512', 'md5', 'sha256', 'sha3-224', 'sha3-256', and 'sha3-512'.


PreviousConsoleNextDebug

Last updated 2 months ago