js-hexi

1.2.0 • Public • Published

JavaScript BaseX converter

Pure JavaScript base encode decoder

Build Status NPM Version npm downloads Standard - JavaScript Style Guide

Javascript Base64, Base16, text to bytes array converter.

Usage

Encoding

Encode "Hello world" to Base64

import JSHexi from "js-hexi";
....
const unibytes = JSHexi.toBytes("Hello world (。◕‿◕。)");
const bytes = JSHexi.toBytes("Hello world", false);
// now bytes contains Uint8Array with bytes
 
JSHexi.toBase64(unibytes);
// Output: AEgAZQBsAGwAbwAgAHcAbwByAGwAZAAgACj/YSXVID8l1f9hACk=
 
JSHexi.toBase64(bytes);
// Output: SGVsbG8gd29ybGQ=

Decoding

Encode "AEgAZQBsAGwAbwAgAHcAbwByAGwAZAAgACj/YSXVID8l1f9hACk=" / "SGVsbG8gd29ybGQ=" to String

import JSHexi from "js-hexi";
....
const bytes = JSHexi.fromBase64("AEgAZQBsAGwAbwAgAHcAbwByAGwAZAAgACj/YSXVID8l1f9hACk=");
const unibytes = JSHexi.fromBase64("SGVsbG8gd29ybGQ=", false);
// now bytes contains Uint8Array with bytes
 
JSHexi.fromBytes(unibytes);
// Output: Hello world (。◕‿◕。)
 
JSHexi.fromBytes(bytes);
// Output: Hello world

More examples

You can see in test folders

Readme

Keywords

none

Package Sidebar

Install

npm i js-hexi

Weekly Downloads

0

Version

1.2.0

License

MIT

Last publish

Collaborators

  • thesimj