OxL Справочник OxL
РусскийEnglish

method aead.unsealChaCha

Verifies and decrypts what sealChaCha produced; a wrong key or modified data is a CryptoError.

Example:

oxl✓ проверяется в CI
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

Параметры

ИмяТип
keybytes
sealedbytes
aadbytes = b""

Возвращает

bytes

Ошибки

  • CryptoError @error
  • `CryptoError` for a wrong key, modified data or different associated data.

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/crypto/crypto.oxl:525

См. также