【发布时间】:2018-09-18 01:41:13
【问题描述】:
目前我正在尝试完成这个挑战 (http://cryptopals.com/sets/1/challenges/1),但我在用 C# 完成任务时遇到了一些麻烦。我似乎无法将数字解析成一个大整数。
所以代码如下所示:
string output = "";
BigInteger hexValue = BigInteger.Parse("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6");
output = Convert.ToBase64String(hexValue.ToByteArray());
Console.WriteLine(hexValue);
Console.WriteLine(output);
Console.ReadKey();
return "";
目前我遇到的问题是,当我运行程序时它失败并出现错误
System.FormatException: '无法解析该值。' 我不完全确定原因。
那么,将大整数从字符串转换为 BigInt 的适当方法是什么?
【问题讨论】:
-
@EhsanSajjad:它是一个整数,但它是十六进制而不是十进制。
标签: c# parsing biginteger