Skip to main content

AES256

An encryption module which lets you encrypt strings with AES256.


Constants

Below are some constants for the encrypt and decrypt functions in out AES256 lib:

sm.scrapcomputers.aes256 = {
AES128 = 128, -- keyLength lookup length (128 Bytes).
AES198 = 198, -- keyLength lookup length (198 Bytes).
AES256 = 256, -- keyLength lookup length (256 Bytes).

ECBMODE = 1, -- ECB mode lookup int.
CBCMODE = 2, -- CBC mode lookup int.
OFBMODE = 3, -- OFB mode lookup int.
CFBMODE = 4, -- CFB mode lookup int.
}

Functions

encrypt

sm.scrapcomputers.aes256.encrypt( password, data, keyLength, mode )

Encrypts a string with AES256.

Arguments:

  • password [ string ] The password to encrypt the data.
  • data [ string ] The data to encrypt.
  • keyLength [ integer? ] The key length to generate from the password, default is 128 bytes, see Constants for more details.
  • mode [ integer? ] The mode AES256 is applied in, default is CBC mode, see Constants for more details.

Returns:

  • [ string ] The encrypted string.

decrypt

sm.scrapcomputers.aes256.decrypt( password, data, keyLength, mode )
Note:

The data you are decrypting has to be decrypted with the same keyLength and mode as when it was encrypted.

Decrypts an AES256 encrypted string.

Arguments:

  • password [ string ] The password to decrypt the data.
  • data [ string ] The data to decrypt.
  • keyLength [ integer? ] The key length to generate from the password, default is 128 bytes, see Constants for more details.
  • mode [ integer? ] The mode AES256 is applied in, default is CBC mode, see Constants for more details.

Returns:

  • [ string ] The decrypted string.