- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
const charTable=[ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', '=' ],allowedPeddingCount=[6,4,3,1,0]; function str_split(str,length){ if(typeof str !== 'string')return []; let a=[],i=0; length||(length=1); do{ a.push(str.substr(i,length)); i+=length; }while(i<str.length); return a; } const Base32={ encode:function(str,padding){ if(!str)return ''; let binaryString=''; for (let i = 0;i<str.length;i++) { let bin=str.charCodeAt(i).toString(2); binaryString+=('0'.repeat(8-bin.length)+bin); } let fiveBitBinaryArray=str_split(binaryString,5),base32=''; for(let i=0;i<fiveBitBinaryArray.length;i++){ let bin=fiveBitBinaryArray[i]; base32+=charTable[parseInt(bin+'0'.repeat(5-bin.length),2)]; } let x=binaryString.length%40; if (padding && x != 0) { if (x == 8)base32+=charTable[32].repeat(6); else if(x===16)base32+=charTable[32].repeat(4); else if(x===24)base32+=charTable[32].repeat(3); else if(x===32)base32+=charTable[32]; } return base32; }, decode:function(str){ if(!str)return ''; let paddingMatch=str.match(/\=+$/), paddingCharCount=paddingMatch?paddingMatch[0].length:0; if(allowedPeddingCount.indexOf(paddingCharCount)<0)return false; for (let i=0;i<4;i++){ if (paddingCharCount===allowedPeddingCount[i] && str.substr(-(allowedPeddingCount[i]))!=charTable[32].repeat(allowedPeddingCount[i])) return false; } str=str.replace(/\=+$/,''); let binaryString = ""; for (let i=0;i<str.length;i+=8) { let x=''; if (charTable.indexOf(str[i])<0)return false; for (let j=0;j<8;j++) { let bin=charTable.indexOf(str[i+j]).toString(2); x+='0'.repeat(5-bin.length)+bin; } let eightBits=str_split(x,8); for (let z = 0; z < eightBits.length; z++) { let y,cd=parseInt(eightBits[z],2,10); binaryString+=((y=String.fromCharCode(cd))||cd==48)?y:""; } } return binaryString; } }
售前咨询
售后咨询
备案咨询
二维码
TOP