有人能把这一小段c#语言写的代码改成python吗?

OPEN_TXEN 2016-07-26 12:55:05
public static int GenerateBetResult(string serverSeed, int clientSeed, int betNumber)
{
Func<string, byte[]> strtobytes = s => Enumerable
.Range(0, s.Length / 2)
.Select(x => byte.Parse(s.Substring(x * 2, 2), NumberStyles.HexNumber))
.ToArray();
byte[] server = strtobytes(serverSeed);
byte[] client = BitConverter.GetBytes(clientSeed).Reverse().ToArray();
byte[] num = BitConverter.GetBytes(betNumber).Reverse().ToArray();
byte[] data = server.Concat(client).Concat(num).ToArray();
using (SHA512 sha512 = new SHA512Managed())
{
byte[] hash = sha512.ComputeHash(sha512.ComputeHash(data));
while (true)
{
for (int x = 0; x <= 61; x += 3)
{
long result = (hash[x] << 16) | (hash[x + 1] << 8) | hash[x + 2];
if (result < 16000000)
return (int)(result % 1000000);
}
hash = sha512.ComputeHash(hash);
}
}
}
...全文
261 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
输入什么,输出什么。了解了自己自己
ztenv 2016-07-28
  • 打赏
  • 举报
回复
这个不难吧?
一起学IT技能 2016-07-28
  • 打赏
  • 举报
回复
逻辑上搞明白是干嘛的 以后应该很简单把

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧