Skip to content

carpentry-org/base64.carp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

base64.carp

A Base64 library for Carp from scratch.

Currently this library exposes ten functions: encode, encode-str, encode-using, decode-using, decode-str, and decode, plus their URL- and filename-safe counterparts encode-url, encode-url-str, decode-url, and decode-url-str. Both encode-str and decode-str take a reference to a string and return a Result, and they implement encoding and decoding using the MIME character set. encode and decode make no such assumptions and deal with binary data (or rather, arrays of byte-sized integers). encode-using and decode-using are their more general sibling functions, as they take in an additional user-supplied character set.

The *-url functions use the URL- and filename-safe alphabet of RFC 4648 section 5, where + and / become - and _. Because URL-safe Base64 is frequently transmitted without padding (for example in JWTs), the decode-url functions accept input both with and without trailing = padding; the encode-url functions always emit padding.

The decode functions return Result, validating that input has correct length, only contains valid characters, and has proper padding placement. If you want, you can check out the documentation online, but it’s very sparse.


Have fun!

About

Base64 as a Carp module

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors