crypto_aead_aes256gcm_encrypt

The function crypto_aead_aes256gcm_encrypt() encrypts a message m using a secret key k (crypto_aead_aes256gcm_KEYBYTES bytes) and a public nonce npub (crypto_aead_aes256gcm_NPUBBYTES bytes). The encrypted message, as well as a tag authenticating both the confidential message m and ad.length bytes of non-confidential data ad, are put into c. ad can also be an empty array if no additional data are required. At most m.length + crypto_aead_aes256gcm_ABYTES bytes are put into c, reflected by the length of c. The function always returns true. The public nonce npub should never ever be reused with the same key. The recommended way to generate it is to use randombytes_buf() for the first message, and then to increment it for each subsequent message using the same key.

  1. alias crypto_aead_aes256gcm_encrypt = deimos.sodium.crypto_aead_aes256gcm.crypto_aead_aes256gcm_encrypt
  2. bool crypto_aead_aes256gcm_encrypt(ubyte[] c, ubyte[] m, ubyte[] ad, ubyte[crypto_aead_aes256gcm_NPUBBYTES] npub, ubyte[crypto_aead_aes256gcm_KEYBYTES] k)
    @nogc @trusted
    bool
    crypto_aead_aes256gcm_encrypt
    (
    scope ubyte[] c
    ,
    scope const ubyte[] m
    ,
    scope const ubyte[] ad
    ,
    const ubyte[crypto_aead_aes256gcm_NPUBBYTES] npub
    ,
    const ubyte[crypto_aead_aes256gcm_KEYBYTES] k
    )

Return Value

Type: bool

See Also

Meta