1.2.0 • Published 7 years ago

js-hexi v1.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago