JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 249
  • Score
    100M100P100Q83991F
  • License MIT

Encoder/Decoder of various algorithm

Package Exports

  • string-codec

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (string-codec) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

string-codec

NPM version Build Status

Encoder/Decoder of various algorithm

Installation

via npm (node package manager)

$ npm install string-codec

Usage Example

Encode to Base64:

var codec = require('string-codec');

codec.encoder('hello','base64');
// => 'aGVsbG8='

Decode from Base64:

var codec = require('string-codec');

codec.decoder('aGVsbG8=','base64')
// => 'hello'

Supported specifications

encoder

algorithm input output
hex string hex string
ascii hex string string
base64 string base64
base85 (z85)) string base85
ascii85 string ascii85
base91 hex string string
rot5/rot13/rot18/rot47 string string
rev (reverse string) string string
crc1/crc8/crc16
crc24/crc32
string crc checksum
adler32 string adler32
url (url encoding) string url encode
unixtime date string unix timestamp
lower string string
upper string string
md4 string md4
md5 string md5
sha string sha
sha1 string sha1
sha224 string sha224
sha256 string sha256
sha384 string sha384
sha512 string sha512
rmd160 string rmd160
whirlpool string whirlpool

decoder

algorithm input output
hex hex string string
ascii string hex string
base64 base64 string
base85 (z85) base85 string
ascii85 ascii85 string
base91 base91 hex string
rot5/rot13/rot18/rot47 string string
rev string string
url url encode string
unixtime unix timestamp date string
md5 md5 string

Input hex string

Accept hex string prefixed with '0x' or separated by a colon (:)

codec.decoder('616263','hex');
// => abc
codec.decoder('0x616263','hex');
// => abc
codec.decoder('61:62:63','hex');
// => abc
codec.decoder('0x61:62:63','hex');
// => abc

Running tests

$ git clone https://github.com/knjcode/string-codec.git
$ cd string-codec
$ npm install
$ npm test

Acknowledgements