做了个小工具,整合了谷歌翻译,但是翻译的汉字变了,tk值也在变,换了汉字用原来的tk就不行了,搞了一晚上了,没找到tk算法。
后来发现错误的tk也能翻译,不知道为什么,先凑合用吧。
JS代码:谷歌翻译tk算法的JS代码,调用 ZL("汉字"),即可返回可用的tk。
var WL = function (a) { return function () { return a } }, XL = function(a, b) { for (var c = 0; c < b.length - 2; c += 3) { var d = b.charAt(c + 2), d = d >= ‘a‘ ? d.charCodeAt(0) - 87 : Number(d), d = b.charAt(c + 1) == "+" ? a >>> d : a << d; a = b.charAt(c) == "+" ? a + d & 4294967295 : a ^ d } return a }, ZL = function(a) { for (var e = [], f = 0, g = 0; g < a.length; g++) { var m = a.charCodeAt(g); 128 > m ? e[f++] = m : (2048 > m ? e[f++] = m >> 6 | 192 : (55296 == (m & 64512) && g + 1 < a.length && 56320 == (a.charCodeAt(g + 1) & 64512) ? (m = 65536 + ((m & 1023) << 10) + (a.charCodeAt(++g) & 1023), e[f++] = m >> 18 | 240, e[f++] = m >> 12 & 63 | 128) : e[f++] = m >> 12 | 224, e[f++] = m >> 6 & 63 | 128), e[f++] = m & 63 | 128) } a = 0; for (f = 0; f < e.length; f++) a += e[f], a = XL(a, "+-a^+6"); a = XL(a, "+-3^+b+-f"); 0 > a && (a = (a & 2147483647) + 2147483648); a = a % 1000000; return (a.toString() + "." + (a)) };
时间: 2024-10-14 09:19:53