method aead.unsealChaCha
Verifies and decrypts what sealChaCha produced; a wrong key or modified data is a CryptoError.
Example:
use std.crypto { aead, CryptoError }
use std.ser { bytesOf }
fn main() io, rand {
let key = bytesOf(&"0123456789abcdef0123456789abcdef")
let sealed = aead.sealChaCha(key, bytesOf(&"hi"), bytesOf(&"ctx-a"))!
match aead.unsealChaCha(key, sealed, bytesOf(&"ctx-b")) {
bytes _ => print("opened")
CryptoError _ => print("refused")
}
}Вывод
refused
pub(api) static fn unsealChaCha(key: bytes, sealed: bytes, aad: bytes = b"") -> bytes | CryptoErrorСложность. O(n) in the size of the message.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
key | bytes |
sealed | bytes |
aad | bytes = b"" |
Возвращает
bytes
Ошибки
CryptoError@error- `CryptoError` for a wrong key, modified data or different associated data.
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/crypto/crypto.oxl:525