package base64
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=b3f5ce301aa72c7032ef90be2332d72ff3962922c00ee2aec6bcade187a2f59b
sha512=82148a1fefec9493aaeac032c8d46b9548369d7fd90a57865e009a32c8a0eef950f0f8dbb52b74bb46880a590a0b49f2daa7ab4857233734aee8e383f5a164ec
doc/base64/Base64/index.html
Module Base64Source
Base64 RFC4648 implementation.
Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. It is specified in RFC 4648.
Release v3.5.2 - https://github.com/mirage/ocaml-base64
Type of alphabet.
Type of sub-string: str, off, len.
A 64-character alphabet specifying the regular Base64 alphabet.
A 64-character alphabet specifying the URI- and filename-safe Base64 alphabet.
decode_exn ?off ?len s decodes len bytes (defaults to String.length s - off) of the string s starting from off (defaults to 0) that is encoded in Base64 format. Will leave trailing NULLs on the string, padding it out to a multiple of 3 characters. alphabet defaults to default_alphabet. pad = true specifies to check if s is padded or not, otherwise, it raises an exception.
Decoder can fail when character of s is not a part of alphabet or is not padding character. If input is not padded correctly, decoder does the best-effort but it does not ensure decode_exn (encode ~pad:false x) = x.
val decode_sub :
?pad:bool ->
?alphabet:alphabet ->
?off:int ->
?len:int ->
string ->
(sub, [> `Msg of string ]) resultSame as decode_exn but it returns a result type instead to raise an exception. Then, it returns a sub string. Decoded input (str, off, len) will starting to off and will have len bytes - by this way, we ensure to allocate only one time result.
val decode :
?pad:bool ->
?alphabet:alphabet ->
?off:int ->
?len:int ->
string ->
(string, [> `Msg of string ]) resultSame as decode_exn, but returns an explicit error message result if it fails.
val encode :
?pad:bool ->
?alphabet:alphabet ->
?off:int ->
?len:int ->
string ->
(string, [> `Msg of string ]) resultencode s encodes the string s into base64. If pad is false, no trailing padding is added. pad defaults to true, and alphabet to default_alphabet.
encode fails when off and len do not designate a valid range of s.
encode_string s encodes the string s into base64. If pad is false, no trailing padding is added. pad defaults to true, and alphabet to default_alphabet.