Skip to content

Encrypt

Source: src/Fly/Encrypt.ts

Encrypt with a Fly SecretKey (nacl_box, nacl_secretbox, xaes256gcm, …). The App and key name are fixed by Encrypt(key).

Provide EncryptHttp on the Action or Service Effect. Fly crypto ops need a KMS token. Org API tokens are typed Forbidden.

const encrypt = yield* Fly.Encrypt(Box);
const { ciphertext } = yield* encrypt({
plaintext: new TextEncoder().encode("attack at dawn"),
});

associatedData is optional AEAD associated data. Decrypt must pass the same bytes.

const { ciphertext } = yield* encrypt({
plaintext: bytes,
associatedData: nonce,
});