Roblox Lua string encryption help

How can I make a string encoded/encrypted with a key that can reverse the encryption? I’ve tried to use many modulescripts but all of them either error or don’t accept my usage cases because it wasn’t documented well enough. Any links would be a great help!

1 Like

Hashing. I think theres like some dude named boat bomber who made a library called sha256 lua

EDIT: found it HashLib - Cryptographic hashes in pure Lua

That’s a cryptographic hash which cannot be reversed and is therefore not of use to OP’s requirement.

1 Like

i thought he wanted to like save a key then check another key but ok :person_shrugging:

Reversal was stated in the first sentence as a primary need for whatever the use is.

1 Like

Do you know of any way to do this, since you made the original lib? I’ve tried using math alongside a key then decoding it but I can’t do it correctly.

May we ask for what purpose? If something is important enough to encrypt, then you may want to ask
yourself if you really want to use a shared/symmetric key algorithm, as you then have the issue of
actually securely sharing the key.

It’s a nice topic, why do any libraries that encode/encrypt get created? I don’t really need it for conventional purposes, just some testing.

MMCraftin made a Module called Encrypt Api
That can Encode on client and server but can only decode on server

1 Like

When I try to use the decode function, it gives me an attempt to call a nil value when I use print(api.decode(key, encoded)). Do you know why?

1 Like

There’s no need for you to reinvent the wheel. I’m sure you can find some library that has the functionality you need.

A quick google search led me to these two resources that seem to be what you’re asking:
https://mkottman.github.io/luacrypto/manual.html

An OpenSSL library is not accessible from Roblox lua. This module was designed to run stand-alone in environments like Roblox. I agree though, other libraries written in C / C++ are much faster and should be used where possible.

1 Like

The module doesn’t let you decode from the client, But if your decoding from the server and its giving you that error then I am not sure why it’s doing that.

Hey, people would likely be interested in an updated version of your Lua AES implementation, now that
Roblox has backported the bit32 lib. Any plans on doing so?

1 Like

About last year I tried to update the module to use the 32 bit library. Unfortunately, AES requires byte operations including shuffling, XORing, and substituting. These operations require breaking up 32 bit numbers, not allowing us to get the full performance of the library. In the end, my original 4 bit XOR lookup table was faster. Please do let me know if you see a way to improve the speed of that operation, it is the bottleneck in this implementation.

Send me your whole code that you are running this in.

1 Like

Why would you actually want to encrypt the strings though?