简体   繁体   English

使用RSA / ECB / PKCS1padding的Android加密问题。 它在Java和Android中给出不同的结果

[英]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.

相关问题 使用RSA / ECB / PKCS1Padding进行.Net加密和Java解密 - .Net encryption and java decryption with RSA/ECB/PKCS1Padding 不同的加密 Android 与纯 Java - RSA/ECB/OAEPWithMD5AndMGF1Padding - Different encryption Android vs pure Java - RSA/ECB/OAEPWithMD5AndMGF1Padding 使用RSA / ECB / PKCS1Padding在Java中进行加密无法在.Net中解密 - Encrypted in Java using RSA/ECB/PKCS1Padding unable to decrypt in .Net Java到ruby的AES / ECB / PKCS5Padding加密 - Java to ruby AES/ECB/PKCS5Padding encryption 在Bouncy Castle中使用“ RSA / ECB / PKCS7Padding” - Using “RSA/ECB/PKCS7Padding” with Bouncy Castle 无法使用AES / ECB / PKCS5Padding将加密方法从Java复制到PHP - Unable to replicate an encryption method from Java to PHP using AES/ECB/PKCS5Padding 使用AES / ECB / NoPadding和PKCS5Padding进行加密 - encryption using AES/ECB/NoPadding vs PKCS5Padding 使用带有PKCS1填充的RSA加密时,C#和Java(Android)有什么区别? - What are the differences between C# and Java (Android) when encrypting using RSA with PKCS1 padding? 使用CBC和PKCS5 / 7的AES加密,使用Java / android中的充气城堡进行填充 - AES Encryption using CBC and PKCS5/7Padding using bouncy castle in java/android .NET 等效于 Java KeyFactory.getInstance "RSA"/"RSA/ECB/PKCS1Padding" - .NET equivalent of Java KeyFactory.getInstance "RSA"/"RSA/ECB/PKCS1Padding"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM