1
realpg 2016-06-30 18:47:43 +08:00
这还不是混淆的……
233333 |
2
b821025551b 2016-06-30 18:48:44 +08:00
这还不是混淆?那什么是混淆?
|
3
yaochiqkl 2016-06-30 19:12:55 +08:00
你应该说出多少钱 233
|
4
xqin 2016-06-30 19:17:02 +08:00
javascript
``` DecodeSomething = function(type, str) { //如果没有传入类型或者字符串(str), 则返回 空数组 if (!type || void 0 === str){ return []; } var decode = function(str) { var b, c = [], d = 3, e = function(a) {//如果字符在 0-9 之间, 则返回它所对应的数字 if(a >= "0" && "9" >= a){ return parseInt(a, 10); }else{//否则返回 它的 unicode 值 减去 87 return a.charCodeAt(0) - 87; } }, f = function(str, index) { var c = e(str[index]), d = e(str[index + 1]) & 15, f = (12 & c) >> 2, g = (2 & c) > 0, h = (1 & c) > 0; return { playerPair: g, winner: f, bankerPair: h, value: d } }; //遍历字符串 for (var index = 0; index < str.length - 1; index += 2){//一次处理两个字符 b = f(str, index); if(b.winner !== d){//如果 winner 的值 不等于 3 c.push(b);//则添加到 数组 c 里面 }else{ c = [];//否则 清空数组 } } return c;//返回数组 c }; switch (type) { case "7bal": case "bal": return decode(str); case "rol": case "rofl": return str.split(";").map(function(val) { return { result: val } }); default: return str } } var a = "60o0749460o07134482"; console.log(JSON.stringify(DecodeSomething("bal", a))); ``` python ``` import string, json def char2int(s): if s >= '0' and s <= '9': return int(s) else: return ord(s) - 87 def decode(str): c = char2int(str[0]) d = char2int(str[1]) & 15 f = (12 & c) >> 2 g = (2 & c) > 0 h = (1 & c) > 0 return {'value': d, 'winner': f, 'playerPair': g, 'bankerPair': h} def DecodeSomething(type, data): c = [] if type in ['7bal', 'bal']: for x in range(0, len(data) - 1, 2): d = decode(data[x:x+2]) if d['winner'] != 3: c.append(d) else: c = [] return c elif type in ['rol', 'rofl']: d = data.split(";") for x in d: c.append({"result": x}) return c else: return data print json.dumps(DecodeSomething("bal", "60o0749460o07134482")) print json.dumps(DecodeSomething("rol", "aa2;asd;42")) ``` 以上内容已发到你的 QQ 邮箱(鉴于 V2EX 对于回复的内容里有代码不够友好的原因, 发邮件给你了). |
5
GhostEX 2016-06-30 19:21:24 +08:00 1
``` javascript
DecodeSomething = function(type, str) { //如果没有传入类型或者字符串(str), 则返回 空数组 if (!type || void 0 === str){ return []; } var decode = function(str) { var b, c = [], d = 3, e = function(a) {//如果字符在 0-9 之间, 则返回它所对应的数字 if(a >= "0" && "9" >= a){ return parseInt(a, 10); }else{//否则返回 它的 unicode 值 减去 87 return a.charCodeAt(0) - 87; } }, f = function(str, index) { var c = e(str[index]), d = e(str[index + 1]) & 15, f = (12 & c) >> 2, g = (2 & c) > 0, h = (1 & c) > 0; return { playerPair: g, winner: f, bankerPair: h, value: d } }; //遍历字符串 for (var index = 0; index < str.length - 1; index += 2){//一次处理两个字符 b = f(str, index); if(b.winner !== d){//如果 winner 的值 不等于 3 c.push(b);//则添加到 数组 c 里面 }else{ c = [];//否则 清空数组 } } return c;//返回数组 c }; switch (type) { case "7bal": case "bal": return decode(str); case "rol": case "rofl": return str.split(";").map(function(val) { return { result: val } }); default: return str } } var a = "60o0749460o07134482"; console.log(JSON.stringify(DecodeSomething("bal", a))); ``` python ``` import string, json def char2int(s): if s >= '0' and s <= '9': return int(s) else: return ord(s) - 87 def decode(str): c = char2int(str[0]) d = char2int(str[1]) & 15 f = (12 & c) >> 2 g = (2 & c) > 0 h = (1 & c) > 0 return {'value': d, 'winner': f, 'playerPair': g, 'bankerPair': h} def DecodeSomething(type, data): c = [] if type in ['7bal', 'bal']: for x in range(0, len(data) - 1, 2): d = decode(data[x:x+2]) if d['winner'] != 3: c.append(d) else: c = [] return c elif type in ['rol', 'rofl']: d = data.split(";") for x in d: c.append({"result": x}) return c else: return data print json.dumps(DecodeSomething("bal", "60o0749460o07134482")) print json.dumps(DecodeSomething("rol", "aa2;asd;42")) ``` |
6
GhostEX 2016-06-30 19:21:58 +08:00
奇怪 好像 markdown 不支持?
|
7
zhuangzhuang1988 2016-06-30 19:38:20 +08:00
访问不了 gist..
|
8
XadillaX 2016-06-30 19:41:42 +08:00
那什么是混淆 2333333
|
9
loudis 2016-06-30 19:49:49 +08:00
还好了,不长
|
10
Light3 2016-06-30 19:53:59 +08:00
大哥参数都 abcd 了 还不混淆。
|
12
pyengwoei OP @zhuangzhuang1988 要梯子
|