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.

Syntax
Luau
syn.crypt.encrypt(data: string, key: string) -> string

Parameters

Function parameters
ParameterTypeDescription
datastringPlaintext bytes.
keystringRaw key material or passphrase used to derive the encryption key.

Returns

string

Base64 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

Example
Luau
local key = "example passphrase"
local sealed = syn.crypt.encrypt("saved note", key)
assert(syn.crypt.decrypt(sealed, key) == "saved note")
Kawaii documentation