怎么用js写自定义key的base64加密
答案:5 悬赏:40 手机版
解决时间 2021-01-26 14:12
- 提问者网友:聂風
- 2021-01-26 05:32
怎么用js写自定义key的base64加密
最佳答案
- 五星知识达人网友:患得患失的劫
- 2021-01-26 05:46
functionBase64(){//privateproperty_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";//publicmethodforencodingthis.encode=function(input){varoutput="";varchr1,chr2,chr3,enc1,enc2,enc3,enc4;vari=0;input=_utf8_encode(input);while(i>2;enc2=((chr1&3)>4);enc3=((chr2&15)>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}elseif(isNaN(chr3)){enc4=64;}output=output+_keyStr.charAt(enc1)+_keyStr.charAt(enc2)+_keyStr.charAt(enc3)+_keyStr.charAt(enc4);}returnoutput;}//publicmethodfordecodingthis.decode=function(input){varoutput="";varchr1,chr2,chr3;varenc1,enc2,enc3,enc4;vari=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i>4);chr2=((enc2&15)>2);chr3=((enc3&3)127)&&(c>6)|192);utftext+=String.fromCharCode((c&63)|128);}else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}returnutftext;}//privatemethodforUTF-8decoding_utf8_decode=function(utftext){varstring="";vari=0;varc=c1=c2=0;while(i191)&&(c
全部回答
- 1楼网友:猎心人
- 2021-01-26 08:31
functionBase64(){//privateproperty_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";//publicmethodforencodingthis.encode=function(input){varoutput="";varchr1,chr2,chr3,enc1,
- 2楼网友:神也偏爱
- 2021-01-26 07:48
functionBase64(){//privateproperty_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";//publicmethodforencodingthis.encode=function(input){varoutput="";varchr1,chr2,chr3,enc1,
- 3楼网友:人间朝暮
- 2021-01-26 07:29
functionBase64(){//privateproperty_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";//publicmethodforencodingthis.encode=function(input){varoutput="";varchr1,chr2,chr3,enc1,
- 4楼网友:执傲
- 2021-01-26 06:10
你好!
functionBase64(){//privateproperty_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";//publicmethodforencodingthis.encode=function(input){varoutput="";varchr1,chr2,chr3,enc1,
如有疑问,请追问。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯