My main focus is to understand the working of string encryption. I don’t fully understand how the string encryption function really works. How would I encrypt and decrypt a string?
What’s your use case? There are many algorithms and ways to implement encryption. You might be interested in symmetric encryption algorithms for different easier-ish implementations.
Maybe this might be useful if you want AES-256: 256-bit Rbx.lua AES encryption
AFAIK Roblox has no built-in encryption library like C# has System.Security.Cryptography
, might be good engine feature request.
Dude, you’re going to have some fun learning about cryptography.
Its a huge topic for sure, and there are many cipher functions around. Each one really has its own process to encrypting a string. AES being a super complicated one, but justly dubbed as the Advanced Encryption Standard. And decryption basically reverses the process of encrypting the string. If you’re familiar with terminal/ bash, then check out some openssl commands to encrypt your own data.
Heres some cool considerations for cipher functions and their design too.
- First ciphers must be reversible, which makes the xor operand very useful.
- They also take in a key (which shouldn’t be repeated ever). You can study the vigenere cipher, which is fairly primitive but its worthwhile knowing how it works and how it can be broken using statistics.
- Encryption functions work as a pseudorandom generator function, taking in a key as seeding. There output encryption should be almost indistinguishable from truly random output.
- There are also several modes of encrypting large amounts of data with a small key rather than a one time pad; split into stream ciphers and block ciphers. For example, AES-CBC and AES_CTR. AES-CBC uses block ciphers, but can be vulnerable to padding oracle attacks. (Which are also fun to know how to do) And AES-CTR is counter mode which acts like a stream cipher with some nonces involved.
You could try some things like, having a string value and making it into a number that represents the string value.
You could simply print the value of this (if it’s the bytecode of the string). Unless you choose to manually define each letter to a different number value