Project started: 6/12/2020, Last updated: 6/12/2020
This is a C++ module for Garry's Mod which allows developers to encode strings to Base64 and decode them from Base64. I decided to make this because as of writing this, Garry's Mod only has a function to encode strings to Base64.
UPDATE: Garry's Mod now has util.Base64Decode() too, so this repository has been archived as it no longer serves much purpose.
- Download the latest release binary file for your server's operating system (
win32
for Windows,osx
for MacOS andlinux
for Linux) - Rename the DLL prefix to match the realm you'll be using it on (Rename it to
gmsv_base64_win32.dll
if you're using it serverside on Windows, orgmcl_base64_win32.dll
if you're using it clientside on Windows, etc.). - Navigate to your server's root directory (where srcds.exe, garrysmod, bin, etc. are).
- Create a new folder inside
garrysmod/lua/
calledbin
if it doesn't already exist. - Place the renamed DLL file into that folder.
- Use the module in any Lua script by calling
require("base64")
.
Here is a basic example on how to use this module:
require("base64")
local myString = "Hello World! This will be converted to Base64!"
local encoded = base64.encode(myString)
print(encoded) -- Should output 'SGVsbG8gV29ybGQhIFRoaXMgd2lsbCBiZSBjb252ZXJ0ZWQgdG8gQmFzZTY0IQ=='
local decoded = base64.decode(encoded)
print(decoded) -- Should output 'Hello World! This will be converted to Base64!'