daily3014/cryptography

Luau implementations of popular hashing/encryption algorithms

Luau Cryptography

Docs Discord Wally Pesde

Luau Cryptography is a library of cryptographic algorithms written in Luau.
It supports Post-Quantum (PQ), Elliptic Curve Cryptography (ECC), authenticated encryption and CSPRNG with many utilities.
See the benchmarks against other Roblox cryptography libraries.

Example

local Cryptography = require(game:GetService("ReplicatedStorage").Cryptography)
local Hashing, Encryption, Verification = Cryptography.Hashing, Cryptography.Encryption, Cryptography.Verification
local CSPRNG = Cryptography.Utilities.CSPRNG

local Message = buffer.fromstring("Hello World")

-- Hash
local Hex = Hashing.SHA2.SHA256(Message)

-- Encrypt and decrypt with ChaCha20-Poly1305
local Key, Nonce = CSPRNG.RandomBytes(32), CSPRNG.RandomBytes(12)
local Ciphertext, Tag = Encryption.AEAD.Encrypt(Message, Key, Nonce)
local Plaintext = Encryption.AEAD.Decrypt(Ciphertext, Key, Nonce, Tag)

-- Sign and verify with Ed25519
local SecretKey = CSPRNG.RandomBytes(32)
local PublicKey = Verification.EdDSA.PublicKey(SecretKey)
local Signature = Verification.EdDSA.Sign(Message, SecretKey, PublicKey)
local IsValid = Verification.EdDSA.Verify(Message, PublicKey, Signature)

Installation

  • Wally: cryptography = "daily3014/[email protected]" under [dependencies]
  • Pesde: pesde add daily3014/cryptography
  • Manual: download the latest release from GitHub and place it in your Roblox Studio project

Disclaimer

While this library has extensive testing, it's always recommended that you do your own tests. Keep in mind that there may be timing vulnerabilities that cannot be fixed due to how Luau compiles functions. This library is NOT intended for exploitation, harassment, illegal activities, or explicit content. All security issues should be reported in the Discord server.

Authors

daily3014 (@daily3014) and Xoifail (@xoifail). Thanks to everyone who gave feedback, tested, contributed and reported bugs.

Contributing and License

Fork this repository, make your changes and open a Pull Request, which needs approval. See CONTRIBUTING.md for guidelines. Licensed under MIT, see LICENSE.


DevForum • Discord • Docs • Wally • Pesde