Java RSA Encrypt - Decrypt .NET

左心房为你撑大大i 提交于 2019-11-30 07:17:40

On the Java side, you need to use "RSA/ECB/PKCS1Padding" as algorithm name. With the plain "RSA" name, Java does not add the PKCS#1 padding which the C# implementation expects, hence the "bad data".

The padding is a transformation of the input data (your encoded string) into a somewhat larger string which has the same length than the RSA modulus (128 bytes here). It is important for security and injects some randomness (the same input string will not yield the same encrypted string every time; but the decryption process removes that randomness and recovers the right string nonetheless).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!