-1

在将此 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(''));
}
4

1 回答 1

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();

现在你有了一段 JavaScript 代码。您需要一个 Javascript 引擎来评估它。

但是,您可以使用以下方法获得相同的结果:

int wphc(){
  return 481450227;
}
于 2013-03-29T09:13:43.030 回答