js代码如下:
_base1KeyStr="ABCDEFGHIJKLMDHDGSY"
function encode(a) {
var f = "", b, c, d, e, g, n, l = 0;
for (a = (a); l < a.length; )
b = a.charCodeAt(l++),
c = a.charCodeAt(l++),
d = a.charCodeAt(l++),
e = b >> 2,
b = (b & 3) << 4 | c >> 4,
g = (c & 15) << 2 | d >> 6,
n = d & 63,
isNaN(c) ? g = n = 64 : isNaN(d) && (n = 64),
f = f + _base1KeyStr.charAt(e) + _base1KeyStr.charAt(b) + _base1KeyStr.charAt(g) + _base1KeyStr.charAt(n);
return f
}
解决方案
40
假如你补齐按 base64 标准补齐 _base1KeyStr
_base1KeyStr=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqistuvwxyz0123456789+/=”
那么你的这个代码就是 base64 编码程序
假如将 _base1KeyStr 打乱,那么就是个加密程序
翻译时只需注意到
c = a.charCodeAt(l++),
d = a.charCodeAt(l++),
在 l 等于 a.length – 1 时,c、d 都是 NaN
而 C# 会报索引越界错
_base1KeyStr=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqistuvwxyz0123456789+/=”
那么你的这个代码就是 base64 编码程序
假如将 _base1KeyStr 打乱,那么就是个加密程序
翻译时只需注意到
c = a.charCodeAt(l++),
d = a.charCodeAt(l++),
在 l 等于 a.length – 1 时,c、d 都是 NaN
而 C# 会报索引越界错