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

data base64

Base64 (RFC 4648): encode with padding, encodeUrl URL-safe without padding; the decoders are strict (alphabet, padding and trailing bits are checked) and return DecodeError.Malformed.

Example:

oxl✓ проверяется в CI
use std.crypto { base64 }
use std.ser { bytesOf, textOf }

fn main() io {
  let text = base64.encode(bytesOf(&"hello"))
  print("{text} {textOf(&base64.decode(text)!)!}")
}
Вывод
aGVsbG8= hello
pub(api) data base64

Потокобезопасность. pure functions; safe from any task.

С версии. 1.0.0-beta

Методы

encode(input: bytes) -> str
Base64 with padding.
encodeUrl(input: bytes) -> str
URL-safe Base64 without padding.
decode(text: str) -> bytes | DecodeError
Strict Base64 decoding (alphabet, padding and trailing bits are checked).
decodeUrl(text: str) -> bytes | DecodeError
URL-safe alphabet; padding is optional.

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

См. также