@keepcoding/bin

1.0.12 • Public • Published

Bin

The Bin is a simple node js library to convert string to binary and binary to string.

How to use

import bin

const bin = require("@keepcoding/bin");

Convert string into Binary

// for space between every byte
const gap = true;

const binary = bin.binary("hello" , gap);

console.log(binary);

// output will be
// 01101000 01100101 01101100 01101100 01101111

Convert binary to String

const string = bin.string("0110100001100101011011000110110001101111");

console.log(binary);

// output will be
// hello

Prettify your Binary

const text = "Hello World";
/* 
    skip used to decide how many skips will be there,
    deafult value of skip is 8
*/
const skip = 8;
/*
    symbol decides which symbol will be used between,
    default value of symbol is " "
*/
const symbol = " ";
let binary = bin.gap(text , skip , symbol);

/*
    Output
    "01001000 01100101 01101100 01101100 01101111 00100000 
    01010111 01101111 01110010 01101100 01100100"
*/

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @keepcoding/bin

    Weekly Downloads

    1

    Version

    1.0.12

    License

    MIT

    Unpacked Size

    9.95 kB

    Total Files

    10

    Last publish

    Collaborators

    • keepcoding