lib.bend checks
raw source on the hub · import 0xd9193642e70279e288909ba354d1bb6a/lib.bend as Lib
Base64 — standard RFC 4648 Base64 over Base's List<&2, U32> and String.
This package intentionally stays Base-only. Input list elements are interpreted as octets: only the low 8 bits of each U32 participate in encoding. Decode returns canonical octets in List<&2, U32>. Invalid alphabet, padding, length, or unused padding bits return None.
1 import
import Base
Definitions
def Base64.alphabet source · line 10 · raw
String
The standard alphabet: A-Z, a-z, 0-9, +, /.
def Base64.char source · line 13 · raw
@+n:U32 -> Char
def Base64.encode.group source · line 18 · raw
@+a:U32 -> @+b:U32 -> @+c:U32 -> String
Encode one complete 24-bit group.
def Base64.encode.one source · line 33 · raw
@+a:U32 -> String
Encode a final one-byte group (two alphabet chars and == padding).
def Base64.encode.two source · line 40 · raw
@+a:U32 -> @+b:U32 -> String
Encode a final two-byte group (three alphabet chars and = padding).
def Base64.encode.go source · line 50 · raw
@xs:List<&2, U32> -> String
Encode octets. The result is padded to a multiple of four characters.
def Base64.encode source · line 61 · raw
@xs:List<&2, U32> -> String
def Base64.value source · line 65 · raw
@+c:Char -> Maybe<&2, U32>
Convert a standard Base64 alphabet character to its sextet value.
def Base64.decode.prefix source · line 80 · raw
@prefix:List<&2, U32> -> @m:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, U32>>
Prepend a decoded group to an already decoded tail, propagating failure.
def Base64.decode.end source · line 90 · raw
@prefix:List<&2, U32> -> @r:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, U32>>
Padding is legal only on the final quartet.
def Base64.decode.full source · line 100 · raw
@r:Maybe<&2, List<&2, U32>> -> @ma:Maybe<&2, U32> -> @mb:Maybe<&2, U32> -> @mc:Maybe<&2, U32> -> @md:Maybe<&2, U32> -> Maybe<&2, List<&2, U32>>
Decode a quartet with no padding into three octets.
def Base64.decode.one_pad source · line 116 · raw
@r:Maybe<&2, List<&2, U32>> -> @ma:Maybe<&2, U32> -> @mb:Maybe<&2, U32> -> @mc:Maybe<&2, U32> -> Maybe<&2, List<&2, U32>>
Decode a quartet ending in one '=' into two octets. RFC 4648 requires the unused low four bits of the second sextet to be zero (canonical padding).
def Base64.decode.two_pad source · line 134 · raw
@r:Maybe<&2, List<&2, U32>> -> @ma:Maybe<&2, U32> -> @mb:Maybe<&2, U32> -> Maybe<&2, List<&2, U32>>
Decode a quartet ending in '==' into one octet. Canonical padding requires the unused low four bits of the second sextet to be zero.
def Base64.decode.quartet source · line 150 · raw
@+a:Char -> @+b:Char -> @+c:Char -> @+d:Char -> @+r:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, U32>>
Decode one quartet. Whitespace is not accepted; callers should normalize it explicitly if a non-RFC transport requires whitespace tolerance.
def Base64.decode.go source · line 166 · raw
@s:String -> Maybe<&2, List<&2, U32>>
Decode padded RFC 4648 Base64. Invalid input returns None.
def Base64.decode source · line 176 · raw
@s:String -> Maybe<&2, List<&2, U32>>