Skip to content

A polyfill to atob/btoa (browser side only) so as to support base64 to/from binary (Uint8Array/ArrayBuffer) conversion

Notifications You must be signed in to change notification settings

tibetty/base64-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

base64-binary

A polyfill built upon atob/btoa (browser) so as to support base64 to/from binary (Uint8Array/ArrayBuffer) conversion

Motivation

It seems that the built-in atob and btoa functions don't support encoding binary (Uint8Array or ArrayBuffer) to base64 string and decoding base64 string to binary directly. However, with the help of this polyfill which adds a thin layer to make extra conversion between String and Uint8Array, we can make it by standing on the shoulders of giants.

Usage

Add reference in your HTML file

...
<script type="text/javascript" src="/path/to/base64-lite.js"></script>
...

Now you can make base64 codec for binary data

const bin = base64.decode("hzw4NdSJ0NzaEKo9hSKiH+X5ViFAh+hmYDuorCqDjEk=");
console.log(base64.encode(bin));

Dependencies

Browser with ES5 support

License

Written in 2019 by tibetty [email protected]

About

A polyfill to atob/btoa (browser side only) so as to support base64 to/from binary (Uint8Array/ArrayBuffer) conversion

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published