Files
Crypto
Base64, hashing and random keys.
crypt
crypt.base64encode(text)
Returns the Base64 form of a string.
crypt.base64decode(text)
Returns the decoded string. Raises the error invalid base64 for invalid input.
crypt.base64.encode(text), crypt.base64.decode(text)
The same functions, under a table.
crypt.base64_encode(text), crypt.base64_decode(text)
More aliases of the same functions.
crypt.hash(data, algorithm = "sha256")
Returns the hash of data as a string. The algorithm is case-insensitive:
| Algorithm | Result |
|---|---|
"sha256" | SHA-256 digest |
"crc32" | CRC-32 as 8 hexadecimal digits |
Any other algorithm raises an error.
crypt.generatekey(length = 32)
Returns a random hexadecimal string.
Global shortcuts
base64_encode(text) and base64_decode(text) exist as globals.
local encoded = crypt.base64encode("hello")
print(encoded, crypt.base64decode(encoded))
print(crypt.hash("hello"))
print(crypt.hash("hello", "crc32"))
print(crypt.generatekey(16))