一小段 js 代码翻译成 Python 或者 C#,谢谢了

2016-06-30 16:11:24 +08:00
 pyengwoei
var a = "60o0749460o07134482";
//var b= parseInt(a, 10);
G = function(a, b) {
var c = function(a)
{
for (var b, c = [], d = 3, e = function(a)
{
return a >= "0" && "9" >= a ? parseInt(a, 10) : a.charCodeAt(0) - "a".charCodeAt(0) + 10
}, f = function(a, b) {
var c, d, f, g, h;
//c =e 函数
return c = e(a[b]), d = e(a[b + 1]), d = 15 & d, f = (12 & c) >> 2, g = (2 & c) > 0, h = (1 & c) > 0,
{
value: d, //d=e 函数
winner: f,// f = (12 & c)
playerPair: g, //g=(2&c)
bankerPair: h // h = (1 & c) > 0
}
},
g = 0; g < a.length - 1; g += 2)
b = f(a, g), b.winner !== d ? c.push(b) : c = [];
return c
};
if (!a || void 0 === b) return [];
switch (a) {
case "7bal":
case "bal":
return c(b);
case "rol":
case "rofl":
return b.split(";").map(function(a) {
return {
result: a
}
});
default:
return b
}
}

document.write(G("bal",a));
7973 次点击
所在节点    程序员
42 条回复
pyengwoei
2016-06-30 16:13:15 +08:00
或者把这段 JS 翻译成通俗一点,也行,实在看不太明白
xcatliu
2016-06-30 16:16:59 +08:00
可以先排版好么……
pyengwoei
2016-06-30 16:22:55 +08:00
var a = "60o0749460o07134482";
//var b= parseInt(a, 10);
G = function(a, b) {
var c = function(a)
{
for (var b, c = [], d = 3, e = function(a)
{
return a >= "0" && "9" >= a ? parseInt(a, 10) : a.charCodeAt(0) - "a".charCodeAt(0) + 10
}, f = function(a, b) {
var c, d, f, g, h;
//c =e 函数
return c = e(a[b]), d = e(a[b + 1]), d = 15 & d, f = (12 & c) >> 2, g = (2 & c) > 0, h = (1 & c) > 0,
{
value: d, //d=e 函数
winner: f,// f = (12 & c)
playerPair: g, //g=(2&c)
bankerPair: h // h = (1 & c) > 0
}
},
g = 0; g < a.length - 1; g += 2)
b = f(a, g), b.winner !== d ? c.push(b) : c = [];
return c
};
if (!a || void 0 === b) return [];
switch (a) {
case "7bal":
case "bal":
return c(b);
case "rol":
case "rofl":
return b.split(";").map(function(a) {
return {
result: a
}
});
default:
return b
}
}

document.write(G("bal",a));
pyengwoei
2016-06-30 16:23:39 +08:00
放到 IDE 里面看 就不会乱 这里排好了发出来 又乱了
whnzy
2016-06-30 16:28:57 +08:00
用 ``` <pre> ```试试
calabashfox
2016-06-30 16:31:03 +08:00
因为做过代码混淆了。。能理清楚也是厉害
DoraJDJ
2016-06-30 16:31:19 +08:00
@pyengwoei 试试 GitHub Gist
pyengwoei
2016-06-30 16:38:57 +08:00
@calabashfox 没有混淆,只是函数名都是 一个字母放在 IDE 里面逻辑很清楚的
ynyounuo
2016-06-30 16:39:20 +08:00
pyengwoei
2016-06-30 16:44:44 +08:00
@ynyounuo 可以付费 OK 了 我发你红包 你留一个支付宝给我
pyengwoei
2016-06-30 16:45:42 +08:00
@DoraJDJ 谢谢 这个真不错 呵呵
pyengwoei
2016-06-30 16:50:28 +08:00
@ynyounuo 你接吗,你接 我就等你的
zrp1994
2016-06-30 16:51:20 +08:00
@pyengwoei
楼主你试试下面这种东西?
https://github.com/PiotrDabkowski/Js2Py
maijiawei
2016-06-30 16:58:09 +08:00
我试着帮你翻译看看
pyengwoei
2016-06-30 16:58:44 +08:00
@maijiawei 好人啊 /(ㄒoㄒ)/~~
pyengwoei
2016-06-30 16:59:31 +08:00
@maijiawei 代码在 9 楼
pyengwoei
2016-06-30 16:59:58 +08:00
@zrp1994 好的我让他们试试
jeremaihloo
2016-06-30 17:09:53 +08:00
强迫症看到你这代码乱的心里好难受,为什么不格式好
maijiawei
2016-06-30 17:10:39 +08:00
这段代码哪里的,功能是什么,混淆过,这代码功能应该是加密解密的?
pyengwoei
2016-06-30 17:11:18 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/289369

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX