nv-facutil-eb64
v1.0.0
Published
nv-facutil-eb64 =============== - nv-facutil-eb64 is a simple wrap of https://www.npmjs.com/package/base64-js - the only difference is its CODES and PADDING is configurable
Downloads
3
Readme
nv-facutil-eb64
- nv-facutil-eb64 is a simple wrap of https://www.npmjs.com/package/base64-js
- the only difference is its CODES and PADDING is configurable
DEFAULT PADDING
'等' the original of base64 is '='
DEFAULT CODES
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789加杠'
the original of base64 is 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
install
- npm install nv-facutil-eb64
usage
const x = require("nv-facutil-eb64");
x.PADDING = '等';
x.CODES = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789加杠'
example
> x.PADDING
'等'
>
> x.CODES
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789加杠'
>
> x.utf8_to_eb64('A')
'QQ等等'
>
> x.eb64_to_utf8('QQ等等')
'A'
>
> x.utf8_to_eb64('𝑒')
'8J2Rkg等等'
> x.eb64_to_utf8('8J2Rkg等等')
'𝑒'
>
> x.utf8_to_eb64('我你他')
'5oiR5L2g5LuW'
> x.eb64_to_utf8('5oiR5L2g5LuW')
'我你他'
>
var s = '//++/++/++//';
> x.utf8_to_eb64(s)
'Ly8rKy8rKy8rKy8v'
>
> x.eb64_to_utf8('Ly8rKy8rKy8rKy8v')
'//++/++/++//'
>
var s = 'SQ==QU0=';
> x.utf8_to_eb64(s)
'U1E9PVFVMD0等'
>
> x.eb64_to_utf8('U1E9PVFVMD0等')
'SQ==QU0='
>
> x.eb64_to_utf8(x.utf8_to_eb64('a'))
'a'
> x.eb64_to_utf8(x.utf8_to_eb64('aa'))
'aa'
> x.eb64_to_utf8(x.utf8_to_eb64('aaa'))
'aaa'
> x.eb64_to_utf8(x.utf8_to_eb64('hi'))
'hi'
> x.eb64_to_utf8(x.utf8_to_eb64('hi!'))
'hi!'
> x.eb64_to_utf8(x.utf8_to_eb64('hi!!'))
'hi!!'
> x.eb64_to_utf8(x.utf8_to_eb64('sup'))
'sup'
> x.eb64_to_utf8(x.utf8_to_eb64('sup?'))
'sup?'
> x.eb64_to_utf8(x.utf8_to_eb64('sup?!'))
'sup?!'
>
API
{
CODE_ERRORS: {
length_must_be_64: 'length_must_be_64',
code_must_be_unique: 'code_must_be_unique',
each_code_length_must_be_1: 'each_code_length_must_be_1',
code_can_not_be_padding: 'code_can_not_be_padding'
},
eb64_to_u8: [Function: eb64_to_u8],
u8_to_eb64: [Function: u8_to_eb64],
utf8_to_eb64: [Function: utf8_to_eb64],
eb64_to_utf8: [Function: eb64_to_utf8]
}
getter/setter
- PADDING default : '等'
- CODES default : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789加杠'
LICENSE
- ISC