js-hexi
v1.2.0
Published
Pure Javasript base encode decoder
Readme
JavaScript BaseX converter
Pure JavaScript base encode decoder
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 worldMore examples
You can see in test folders
