Skip to content

RexBerry/basek

Repository files navigation

Basek

A family of efficient base-k binary-to-text encodings.

What is Basek?

Basek is a family of binary-to-text encodings similar to Base64 and Ascii85. Unlike Base64 and Ascii85, Basek does not use a fixed alphabet. Instead, it can use any alphabet with between 2 and 94 non-whitespace, printable ASCII characters. Since the alphabet size, and therefore base/radix, is flexible, Basek is a base-k encoder and decoder, not just base-64 or base-85.

Size Overhead

Basek uses range coding with up to 45 bits of precision, which in some cases reduces the size overhead of encoded strings. For example, using a Basek base-85 encoding, encoded strings are approximately 24.81686% larger than the original data, which is almost exactly the ideal overhead. In comparison, data encoded using Ascii85 becomes 25% larger1, since Ascii85 encodes groups of four bytes as five characters. The difference is not much, but it does exist.

1 Ascii85 encodes series of four 0 bytes as one character, but in compressed data, the difference this makes is negligible.

Performance

This implementation of Basek, written in TypeScript, is quite slow. The following table shows approximate performance on my machine:

Function Speed
Base-85 Encode 45 MB/s
Base-85 Decode 30 MB/s
btoa() 1 GB/s
atob() 1 GB/s

About

Basek - A family of efficient base-k binary-to-text encodings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published