RSA
The RSA cryptography functions are provided under the crypt.rsa
namespace.
generate_key_pair
function crypt.rsa.generate_key_pair(bits: number): (string, string)
Generates an RSA key pair.
Example
local public_key, private_key = crypt.rsa.generate_key_pair(2048)
encrypt
function crypt.rsa.encrypt(plaintext: string, public_key: string): string
Encrypts data using RSA public key.
Example
local encrypted = crypt.rsa.encrypt("Secret message", public_key)
decrypt
function crypt.rsa.decrypt(ciphertext: string, private_key: string): string
Decrypts RSA encrypted data using private key.
Example
local decrypted = crypt.rsa.decrypt(encrypted, private_key)
sign
function crypt.rsa.sign(data: string, private_key: string): string
Signs data using RSA private key.
Example
local signature = crypt.rsa.sign("Data to sign", private_key)
verify
function crypt.rsa.verify(data: string, signature: string, public_key: string): boolean
Verifies an RSA signature.
Example
local is_valid = crypt.rsa.verify("Data to verify", signature, public_key)