Since | Origin / Contributor | Maintainer | Source |
---|---|---|---|
2016-02-26 | Terry Ellison | Terry Ellison | encoder.c |
The encoder modules provides various functions for encoding and decoding byte data.
Provides a Base64 representation of a (binary) Lua string.
b64 = encoder.toBase64(binary)
binary
input string to Base64 encode
A Base64 encoded string.
print(encoder.toBase64(crypto.hash("sha1","abc")))
Decodes a Base64 representation of a (binary) Lua string back into the original string. An error is thrown if the string is not a valid base64 encoding.
binary_string = encoder.toBase64(b64)
b64
Base64 encoded input string
The decoded Lua (binary) string.
print(encoder.fromBase64(encoder.toBase64("hello world")))
Provides an ASCII hex representation of a (binary) Lua string. Each byte in the input string is represented as two hex characters in the output.
hexstr = encoder.toHex(binary)
binary
input string to get hex representation for
An ASCII hex string.
print(encoder.toHex(crypto.hash("sha1","abc")))
Returns the Lua binary string decode of a ASCII hex string. Each byte in the output string is represented as two hex characters in the input. An error is thrown if the string is not a valid base64 encoding.
binary = encoder.fromHex(hexstr)
hexstr
An ASCII hex string.
Decoded string of hex representation.
print(encoder.fromHex("6a6a6a")))