C# 如何将bigint与C结合使用?
我致力于实现一个密钥算法。但我不能使用2048位的值。我如何使用它C# 如何将bigint与C结合使用?,c#,biginteger,C#,Biginteger,我致力于实现一个密钥算法。但我不能使用2048位的值。我如何使用它 我想使用大整数。在.NET 4.0中引入了对大整数的本机支持。只需向System.Numerics添加一个程序集引用,就可以使用System.Numerics添加一个程序集引用;声明在代码文件的顶部,您就可以开始了。您要查找的类型是。您可以使用System.Numerics.BigInteger添加对System.Numerics程序集的引用。正如评论中提到的,这可能不是正确的方法。在.NET 4.0或更高版本中提供。如果您使用
我想使用大整数。在.NET 4.0中引入了对大整数的本机支持。只需向System.Numerics添加一个程序集引用,就可以使用System.Numerics添加一个程序集引用;声明在代码文件的顶部,您就可以开始了。您要查找的类型是。您可以使用System.Numerics.BigInteger添加对System.Numerics程序集的引用。正如评论中提到的,这可能不是正确的方法。在.NET 4.0或更高版本中提供。如果您使用的是早期版本的框架。最好使用System.Numerics.BigInteger。这里使用BigInteger。此方法按斐波那契数列打印最大为n的数字
通常RSA密钥算法一次工作8位。您的密钥将放置在一个具有8个索引的字节数组中。不重复。ı不希望使用long或int64。它们对我来说还不够,大整数才是出路。次要说明:它仅在.NET4.0及更高版本中可用。
public static void FibonacciSequence(int n)
{
/** BigInteger easily holds the first 1000 numbers in the Fibonacci Sequence. **/
List<BigInteger> fibonacci = new List<BigInteger>();
fibonacci.Add(0);
fibonacci.Add(1);
BigInteger i = 2;
while(i < n)
{
int first = (int)i - 2;
int second = (int) i - 1;
BigInteger firstNumber = fibonacci[first];
BigInteger secondNumber = fibonacci[second];
BigInteger sum = firstNumber + secondNumber;
fibonacci.Add(sum);
i++;
}
foreach (BigInteger f in fibonacci) { Console.WriteLine(f); }
}