PublicKey and PrivateKey constructor in Android (Java)
i want to keep the public and private keys I've generated wi开发者_开发百科th my application in a file so I could use the exact same keys another time.. but i realize that there isn't any constructor for PublicKey and PrivateKey object in Android.. so when I could keep them and read them, I still can't reuse them in my application..
could someone tell me how the way that it could be done?
The getEncoded methods of PublicKey and PrivateKey return byte arrays that should be suitable for supplying to the constructors for X509EncodedKeySpec (for the PublicKey) and PKCS8EncodedKeySpec (for the PrivateKey). These KeySpecs in turn may be used with the appropriate KeyFactory to regenerate the private keys.
精彩评论