Import std.crypto.ciphers
Aes256Gcm
struct
Public Struct Aes256Gcm
AES-256 in GCM (NIST SP 800-38D), fast where the CPU has AES instructions.
Examples
Local key = Aes256Gcm.NewKey()
Local sealed = Aes256Gcm.Seal(key, "meet at noon")
Expect(Aes256Gcm.Open(key, sealed) == "meet at noon".Bytes)
// A changed byte, or another key, opens nothing.
sealed[20] = sealed[20] ^ 1
Expect(Aes256Gcm.Open(key, sealed) == Null)
Expect(Aes256Gcm.Open(Aes256Gcm.NewKey(), Aes256Gcm.Seal(key, "hi")) == Null)std/crypto/ciphers.fb, line 36
-
A new random key, 32 bytes.
-
@PanicsAtCaller Public Static Method Seal(key: UInt8[], message: UInt8[], associated: UInt8[] = []): UInt8[]static method #message, encrypted withkey, 32 bytes: the nonce, 12 bytes, the ciphertext, as long asmessage, and the tag, 16 bytes, which authenticates them andassociated, data that isn't encrypted but has to be the same to open it. Panics unlesskeyis 32 bytes. -
@PanicsAtCaller Public Static Method Seal(key: UInt8[], text: String, associated: UInt8[] = []): UInt8[]static method #text's UTF-8 bytes, encrypted withkey, as the Seal that takes bytes does. -
@PanicsAtCaller Public Static Method Open(key: UInt8[], sealed: UInt8[], associated: UInt8[] = []): UInt8[]?static method #The message Seal sealed into
sealed, or Null whensealedisn't what Seal gave forkeyandassociated, or was changed. Panics unlesskeyis 32 bytes.
Report an issue with this page or with FutureBlitz on GitHub.