当前位置:网站首页>JS to implement encode64 encryption
JS to implement encode64 encryption
2022-07-23 14:13:00 【Kai Xiaomo】
var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "=";
function encode64(input) {
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2)
+ keyStr.charAt(enc3) + keyStr.charAt(enc4);
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";
} while (i < input.length);
return output;
}
边栏推荐
猜你喜欢
随机推荐
How can Creo 9.0 quickly modify CAD coordinate system?
What level is the notebook core i5 1135g7 equivalent to? How about i5 1135g7 performance
Uiscrollview (uicollectionview) prohibits horizontal and vertical sliding at the same time
天玑820相当于骁龙多少处理器 天玑1100相当于骁龙多少 天玑820怎么样
Detailed introduction of RIP
记一次Vulnhub靶机练习成功拿下root权限
How to judge whether an object is empty
数据库连接池 & DBUtils
强化学习——策略梯度理解点
JS数据类型判断方式总结
Static comprehensive experiment (HCIA)
Swift 16进制字符串与UIColor互转
How about Celeron n5095 Processor? What is the equivalent level of Intel n5095 core display
NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library ‘*****‘
配置firecracker流程即踩坑记录
canvas橡皮擦功能
Best practices of JD cloud Distributed Link Tracking in financial scenarios
mysql开启定时调度任务执行
容器网络原理
Differences between Xiaomi 12s pro and Xiaomi 12pro Tianji version configuration comparison between the two








