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

fn seal

Encrypts one field of a topic element (@encrypted fields, §13.3): AES-256-GCM with the data key topic/<name>/<field> of the node's KMS (D-4663). Store the result in a bytes field of the element; open reverses it. The field name is bound to the ciphertext, so it does not open under another field.

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"))?
  let plain = unseal("Payments", "card", sealed)?
  print("{Utf8.decode(plain)!}")
}
Вывод
4111
pub(api) fn seal(name: str, field: str, plain: bytes) -> bytes | TopicError  db

Сложность. O(size of the field).

С версии. 1.0.0-beta

Параметры

ИмяТип
namestr
fieldstr
plainbytes

Возвращает

bytes

Ошибки

  • TopicError @error
  • `TopicError` when the data key is not available.

Эффекты

db

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

См. также