views:

55

answers:

2

How can I convert RSAPublicKey into something readable (public key sharing reasons) and then convert it back to RSAPublicKey?

A: 

The easiest way to share the key between Java programs is to generate the key in keytool and share the keystore file.

ZZ Coder
+3  A: 

The getEncoded() method gets you a byte array, which you can then convert to a string in hexadecimal representation (or, if you want to get cleverer about it, have a set 256 words you can use to represent each byte!) Similar idea on the way back. Once you convert it back to a byte array there should be a constructor you can pass it to.

Evgeny
(I wouldn't have called a sequence of `2048 / 8` random words "clever" ...)
Stephen C
Yeah, it's not *too* readable, but if the words are easy to pronounce it may still be easier to read them over the phone than hexadcimal numbers. :)
Evgeny
Is there any standard format for sharing public keys, for example, in what format are PGP public keys shared?
dede