js-base64-extend
v2.0.2
Published
基于base64上扩展,增加设置key,支持node和浏览器端
Downloads
6
Readme
js-base64-extend
项目介绍
基于base64上扩展,增加设置key,支持node和浏览器端
安装
- (c)npm install js-base64-extend -D
使用
浏览器
<script src="dist/js-base64-extend-browser.min.js"></script>
jsBase64Extend.setCharsKey('QWERTYUIOPASDFGHJKLZXCVBNM1234567890+/=qwertyuiopasdfghjklzxcvbnm');
var str = jsBase64Extend.encode(JSON.stringify({
description: '可用于框架中和node配合使用',
api: {
'setCharsKey': {
type: 'function',
param: 'string',
return: 'void',
tips: '尽量设置值为A-z0-9+=/混合'
},
'encode': {
type: 'function',
param: 'string',
return: 'string'
},
'decode': {
type: 'function',
param: 'string',
return: 'string'
},
}
}));
console.log(jsBase64Extend.decode(str))
nodejs
const {jsBase64Extend} = require('js-base64-extend');
jsBase64Extend.setCharsKey('QWERTYUIOPASDFGHJKLZXCVBNM1234567890+/=qwertyuiopasdfghjklzxcvbnm');
console.log(jsBase64Extend.encode('test string')); // wImE51QHPe14Ofx22u58NI51EQaBw21oEy23tXx58vuXee51CX15pH16cEC48KBZc62gFaP64aNJ60d38CnCwZj
console.log(jsBase64Extend.decode('wImE51QHPe14Ofx22u58NI51EQaBw21oEy23tXx58vuXee51CX15pH16cEC48KBZc62gFaP64aNJ60d38CnCwZj')); // test string
vue
// main.js
import {jsBase64Extend} from 'js-base64-extend';
Vue.prototype.jsBase64Extend = jsBase64Extend;
Vue.prototype.jsBase64Extend.setCharsKey('QWERTYUIOPASDFGHJKLZXCVBNM1234567890+/=qwertyuiopasdfghjklzxcvbnm');
// component
console.log(this.jsBase64Extend.encode('test string')); // gfmXr51lVB14LNE22dv58gQ51sfNEH21bdArx23m58TYSK51rZ15REK16ib48vFtw62XVkX64XAFD60Kd38YErdHG
console.log(this.jsBase64Extend.decode('gfmXr51lVB14LNE22dv58gQ51sfNEH21bdArx23m58TYSK51rZ15REK16ib48vFtw62XVkX64XAFD60Kd38YErdHG')); // test string