RSA on Android is different from PC

南笙酒味 提交于 2019-12-07 08:26:31

That does look like a different key. Please try again as you've probably send an old key or something. Make sure you don't regenerate the key pair, it will be different each time. Use the private key to print out the modulus as BigInteger instead; BigInteger instances will always print out as decimals making for an easier comparison. Or even better, use BigInteger.toString(16) to get a hexadecimal representation.

If you use a good random number generator (like the default one in Java) then the modulus should be unique for the key pair. Therefore it, or the SHA1 hash over the modulus is normally used to identify the key.

kroot

They're the same thing, but Android prints it out in base 16 (hexadecimal) whereas your desktop's Java is printing it in base 10 (decimal). You'll see variations of the output of toString() between different implementations.

For instance, look at the public exponent and note that hex 0x10001 is equal to decimal 65537. This exponent is commonly known as RSA F4. However as this public exponent is used for a lot of keys, you cannot use it to distinguish between keys.

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