secretbox_open

High-level symmetric authenticated decryption.

ubyte[]
secretbox_open
@safe
(
in ubyte[] boxed
,
in ubyte[] nonce
,
in ubyte[] key
)
in { assert (key.length == key_bytes, "Invalid key length."); assert (nonce.length == nonce_bytes, "Invalid nonce length."); assert (boxed.length >= tag_bytes, "Message too short. Can't even contain a 16 byte tag."); }

Parameters

boxed
Type: ubyte[]

Ciphertext and authentication tag as created by secretbox().

nonce
Type: ubyte[]

24 bytes used once per key.

key
Type: ubyte[]

Secret shared key. 32 bytes.

Return Value

Type: ubyte[]

Returns the plaintext if the authentication tag is correct.

Throws

Throws an exception if the authentication tag is invalid.

Meta