[英]Issue in Android Encryption using RSA/ECB/PKCS1padding. It gives different results in Java and Android
I am facing one strange issue. 我面临一个奇怪的问题。 My server is giving me public key to encrypt the user name and password. 我的服务器为我提供了用于加密用户名和密码的公共密钥。
It is giving different result if we use rsa/ecb/pkcs1padding (Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding")) algorithm. 如果使用rsa / ecb / pkcs1padding(密码算法= Cipher.getInstance(“ RSA / ECB / PKCS1Padding”))算法,则会得到不同的结果。 Same algorithm is using in Java server and android, but it gives different results. Java服务器和android使用相同的算法,但结果不同。
If we use RSA/ECB/NOPADDING algorithm, both results are same and working fine. 如果我们使用RSA / ECB / NOPADDING算法,则两个结果相同且工作正常。 But i need to implement rsa/ecb/pkcs1padding in android. 但是我需要在android中实现rsa / ecb / pkcs1padding。
Please help to identify the issue ? 请帮忙找出问题所在?
Thanks. 谢谢。
这是因为有填充功能,所以当您使用PKCS#1填充和其他方式时,它将生成一个随机数并使每次的密文文本都不同。
I didn't know much about RSA
algorithm. 我对RSA
算法了解不多。
I found it will have always different encryption result with same key
in RSA
with padding. 我发现在带有填充的RSA
,使用相同的key
将始终具有不同的加密结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.