syn. crypt. encrypt Synchronous
syn.crypto.encrypt
Encrypt bytes in Kawaii’s versioned Synapse-compatible envelope. This is useful when a script already uses syn.crypt and needs a ciphertext that its matching decrypt call can read.
Luau
syn.crypt.encrypt(data: string, key: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
data | string | Plaintext bytes. |
key | string | Raw key material or passphrase used to derive the encryption key. |
Returns
stringBase64 text containing the envelope version, a random nonce, and authenticated ciphertext.
Usage notes
Use syn.crypt.decrypt with the same key. This local envelope is different from the format returned by crypt.encrypt.
A fresh nonce is generated for each call, so encrypting identical plaintext twice can produce different output.
Availability
This function requires the Synapse environment setting, which is off by default.
Example
Luau
local key = "example passphrase"
local sealed = syn.crypt.encrypt("saved note", key)
assert(syn.crypt.decrypt(sealed, key) == "saved note")