我正在尝试在 C# 中实现 RSA 加密。我让它使用这样的小键:
public static int n = 33;
public static int e = 7;
public static int d = 3;
static void Main(string[] args)
{
int A = 9;
int enc = (int)(Math.Pow(A, e) % n);
int dec = (int)(Math.Pow(enc, d) % n);
Console.WriteLine(A);
Console.WriteLine(enc);
Console.WriteLine(dec);
}
这输出:
9
15
9
我不明白为什么它不适用于较大的键。如果我给出这些关键值:
public static int n = 3233;
public static int e = 17;
public static int d = 2753;
它输出:
9
1971
-2147483648
根据维基百科(并使用大学网站上的 RSA 计算器进行检查),n=3233 e=17 d=2753 是有效的 RSA 密钥集。
有人可以解释为什么我没有得到预期的输出吗?