Lyricdev
GitHub

struct Base64Url

pub struct Base64Url

Base64 with the URL- and file-safe alphabet (RFC 4648 §5), - and _, padded as Base64 is.

Methods

pub static fn encode(bytes: Slice<uint8>): string

Returns bytes as padded URL-safe Base64 text.

pub static fn decode(s: StringView): uint8[] throws EncodingError

Returns the bytes that the padded URL-safe Base64 text s encodes.

Errors

Throws EncodingError as Base64.decode does.

pub static fn encodeUnpadded(bytes: Slice<uint8>): string

Returns bytes as URL-safe Base64 text without the = padding, the form of RFC 7515 §2. The text's length is 4k, 4k + 2 or 4k + 3.

pub static fn decodeUnpadded(s: StringView): uint8[] throws EncodingError

Returns the bytes that the unpadded URL-safe Base64 text s encodes; as strict as Base64Url.decode.

Errors

Throws EncodingError for a = anywhere, at the end for a length of 4k + 1, for a character outside the alphabet, and for bits past the last byte that are not zero.