当前位置:网站首页>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;
}
边栏推荐
- 第八天笔记
- Thousands of databases, physical machines all over the country, JD logistics full volume cloud live record | interview with excellent technical team
- 生活随笔:2022烦人的项目
- rip的详细介绍
- 笔记本酷睿i5 1135g7相当于什么水平?i5 1135g7性能怎么样
- How about the performance of Ruilong R7 Pro 5875u? What level is it equivalent to
- Notes on the seventh day
- Rip experiment
- 《Animal Farm》笔记
- How about Celeron n5095 Processor? What is the equivalent level of Intel n5095 core display
猜你喜欢

MYSQL练习题:向CEO汇报的所有员工

Is machine learning difficult to get started? Tell me how I started machine learning quickly!

第五天实验

赛扬n5095处理器怎么样 英特尔n5095核显相当于什么水平

How about the performance of Intel Celeron 7300? What level is it equivalent to

rtx3070ti显卡什么水平 rtx3070ti显卡什么级别 rtx3070ti显卡怎么样

excel随笔记录

PyTorch到底好用在哪里?

Tensor、Numpy、PIL格式转换以及图像显示

What level is the Core i7 1165g7 equivalent to? What grade does the i71165g7 belong to
随机推荐
rip的详细介绍
OSPF details (1)
JS数据类型判断方式总结
第五天筆記
iQOO 10 Pro和小米12 Ultra哪个好 哪个值得买 两者配置对比
PyTorch到底好用在哪里?
How about Celeron n5095 Processor? What is the equivalent level of Intel n5095 core display
rtx3080ti和3090差距 rtx3080ti和3090哪个性价比高
HCIA的复习
英特尔赛扬7300性能怎么样?相当于什么水平级别
Notes on the fourth day
Rtx3080ti and rtx3080 gap 3080 and 3080ti parameter comparison
canvas橡皮擦功能
Day 10 notes
Day 12 notes
判断一个对象是否是空对象的处理办法
天玑720相当于骁龙多少处理器 天玑720相当于骁龙多少 天玑720怎么样
Best practices of JD cloud Distributed Link Tracking in financial scenarios
200 lines of code, in-depth analysis of the principle and implementation of dynamic calculation diagram
OSPF综合实验