在将这个javascript转换为C#时,我有点困惑......
任何帮助将不胜感激!
这是javascript:
function wphc(){
var wphc_data = [1017872750,833265020,934642472,816229227,732988517,619502701,716280186,1843763834,1861340473,1843781160,1861340473,1810226984,1777451834,2142819379,1018004607,850040663,984711544,2147409184];
for (var i=0; i<wphc_data.length; i++){
wphc_data[i]=wphc_data[i]^1606808584;
}
var a = new Array(wphc_data.length);
for (var i=0; i<wphc_data.length; i++) {
a[i] = String.fromCharCode(wphc_data[i] & 0xFF, wphc_data[i]>>>8 & 0xFF, wphc_data[i]>>>16 & 0xFF, wphc_data[i]>>>24 & 0xFF);
}
return eval(a.join(''));
}
答案 0 :(得分:0)
将数字转换为文本的部分很简单:
int[] wphc_data = { 1017872750, 833265020, 934642472, 816229227, 732988517, 619502701, 716280186, 1843763834, 1861340473, 1843781160, 1861340473, 1810226984, 1777451834, 2142819379, 1018004607, 850040663, 984711544, 2147409184 };
for (var i = 0; i < wphc_data.Length; i++) {
wphc_data[i] = wphc_data[i] ^ 1606808584;
}
var a = new StringBuilder();
for (var i = 0; i < wphc_data.Length; i++) {
a.Append((char)(wphc_data[i] & 0xFF));
a.Append((char)(wphc_data[i] >> 8 & 0xFF));
a.Append((char)(wphc_data[i] >> 16 & 0xFF));
a.Append((char)(wphc_data[i] >> 24 & 0xFF));
}
string code = a.ToString();
现在你有了一段Javscript代码。你需要一个Javascript引擎来评估它。
但是,您可以使用以下方法获得相同的结果:
int wphc(){
return 481450227;
}