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

fn open

Decrypts what seal produced for the same topic and field. Import it as unseal: open is a keyword in import lists.

Example:

oxl✓ проверяется в CI
use std.topic { seal, unseal }
use std.core { Utf8 }

fn main() -> () | TopicError io, db {
  let sealed = seal("Payments", "card", Utf8.encode("4111"))?
  match unseal("Payments", "pan", sealed) {
    bytes _ => print("opened")
    TopicError _ => print("wrong field")
  }
}
Вывод
wrong field
pub(api) fn open(name: str, field: str, sealed: bytes) -> bytes | TopicError  db

С версии. 1.0.0-beta

Параметры

ИмяТип
namestr
fieldstr
sealedbytes

Возвращает

bytes

Ошибки

  • TopicError @error
  • `TopicError` when the ciphertext was changed or belongs to another topic or field.

Эффекты

db

Определено в: std/topic/topic.oxl:740

См. также