Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我的简单RSA加密器/解密器无法处理3以上的值?_Java_Encryption_Rsa_Public Key Encryption - Fatal编程技术网

Java 我的简单RSA加密器/解密器无法处理3以上的值?

Java 我的简单RSA加密器/解密器无法处理3以上的值?,java,encryption,rsa,public-key-encryption,Java,Encryption,Rsa,Public Key Encryption,所以我有一个问题,我今天早上刚刚学会了如何使用以下变量对RSA加密/解密: p = 5, q = 11, n = 55, PHI = 40, e = 11, d = 11 当我把它输入这个(顺便说一下,这是JAVA): 但当我输入任何三个或以上的内容时,我会在控制台中看到: 1 This is the ecripted message 1.0 This is the origanal message 1.0 2 This is the ecripted message 13.

所以我有一个问题,我今天早上刚刚学会了如何使用以下变量对RSA加密/解密:

p = 5, 
q = 11, 
n = 55, 
PHI = 40, 
e = 11, 
d = 11
当我把它输入这个(顺便说一下,这是JAVA):

但当我输入任何三个或以上的内容时,我会在控制台中看到:

1

This is the ecripted message 1.0

This is the origanal message 1.0

2

This is the ecripted message 13.0

This is the origanal message 2.0

3

This is the ecripted message 47.0

This is the origanal message 24.0

请记住,我是一个非常未过期的程序员,我是一个相对新的

47^11(与13^11一样,但在这种情况下,您很幸运使用了模运算)太大,无法存储在
int
中,您正在经历整数溢出。您需要使用一些其他的数字计算系统,看看BigInteger类。正如Jean Babtiste所指出的,您需要处理较大数字的东西。47^11是2472159215084012303,mod 55给出的是3,而不是24。打印出47^11的计算值,您可能会发现它由于溢出而被截断。是的,您需要模幂运算。模幂运算与幂运算不同,如果数有最大值,则取模。您可能会遇到以下两个问题:1)您有数字溢出(不幸的是,对于基本类型,Java中从未抛出异常);2)您会遇到内存和性能问题。从概念上讲:内部乘法也需要以n模执行。谢谢您的帮助!虽然你说我需要一些能处理更大数字的东西,但2014年初开始在MacBookPro上使用3.0GHz和8G内存的eclipse还不够吗?
1

This is the ecripted message 1.0

This is the origanal message 1.0

2

This is the ecripted message 13.0

This is the origanal message 2.0

3

This is the ecripted message 47.0

This is the origanal message 24.0