syn. crypt. encrypt Synchronous
syn.crypto.encrypt
Encrypt a byte string using the Synapse compatibility library’s local ciphertext format. Use it when both sides of a local data round trip use this compatibility format. Its output cannot be substituted for the separate ciphertext and IV returned by crypt.encrypt.
Luau
syn.crypt.encrypt(data: string, key: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
data | string | Plaintext bytes to encrypt. |
key | string | Raw input key material used by this library to derive the encryption key. |
Returns
stringA Base64 ciphertext envelope containing the nonce and encrypted data.
Usage notes
This uses a Kawaii-specific versioned format. Pass its output to syn.crypt.decrypt with the same key; it is a different format from crypt.encrypt.
Availability
This function requires the Synapse environment setting, which is off by default.
Example
Luau
-- Enable the Synapse environment setting before running this example.
local key = syn.crypt.random(32)
local ciphertext = syn.crypt.encrypt("example note", key)
print(syn.crypt.decrypt(ciphertext, key)) -- example note