decode-encode-binary
Version:
Lightweight Module and CLI to encode, decode and auto-detect binary numbers
83 lines (71 loc) • 3.81 kB
Markdown
# Decode and encode text to binary #
### Node module and CLI to encode, decode and auto-detect binary numbers ###
[](https://travis-ci.org/TheChickenNagget/decode-encode-binary)
[](https://packagephobia.now.sh/result?p=decode-encode-binary)
[](https://www.npmjs.com/package/decode-encode-binary)
[](https://www.codacy.com/manual/chickennagget14/decode-encode-binary?utm_source=github.com&utm_medium=referral&utm_content=TheChickenNagget/decode-encode-binary&utm_campaign=Badge_Grade) 

## Installation ##
##### Using [npm](https://www.npmjs.com/package/decode-encode-binary) #####
```shell
$ npm install decode-encode-binary
```
##### Using [Yarn](https://yarnpkg.com/en/package/decode-encode-binary) #####
```shell
$ yarn add decode-encode-binary
```
------
## Using in Terminal ##
- Using in Terminal/Console Requires To Have package installed with `--global` Tag
```shell
$ enc encode ay
$ 001000000110000101111001
```
```shell
$ dec decode 001000000110000101111001
$ ay
```
## Examples ##
### An example decoding text from binary numbers ###
------
```js
const test = require("decode-encode-binary")
console.log(test.decode("0110100001100101011011000110110001101111001000000111011101101111011100100110110001100100"))
// outputs "hello world"
```
------
### Example encoding text to binary numbers ###
```js
const test = require("decode-encode-binary")
console.log(test.encode("Hello world!"))
// outputs "01101000011001010110110001101100011011110111011101101111011100100110110001100100"
```
### Example using Auto Detecting function ###
```js
const test = require("decode-encode-binary")
console.log(test.auto("ok"))
// outputs 0110111101101011
console.log(test.auto("01101111 01101011"))
// outputs "ok"
```
------
## Other Examples ##
### Making spaces between every letter in binary ###
##### ( Only Decoding/Encoding Works With This Feature ) #####
```js
const test = require("decode-encode-binary")
console.log(test.encode("ay", true))
// outputs "01100001 01111001"
/* Auto detection support */
console.log(test.auto("ay", true))
// outputs "01100001 01111001" too
```
## Browser Support ##
> [](https://github.com/TheChickenNagget/assets/tree/master/decode-encode-binary-npm)
[](https://raw.githubusercontent.com/TheChickenNagget/assets/master/decode-encode-binary-npm/browser_lastest.js)
------
[](https://github.com/TheChickenNagget/decode-encode-binary/issues/new)
[](https://github.com/TheChickenNagget/decode-encode-binary/fork)
[](https://github.com/TheChickenNagget/decode-encode-binary/stargazers)
[](https://npm.runkit.com/decode-encode-binary)
