Sunday, 15 May 2011

java - Write public key on a file and read with objectInputStream -



java - Write public key on a file and read with objectInputStream -

i need save public key in file , read. so, steps:

keypair keypair = kpg.generatekeypair(); privatekey privatekey = keypair.getprivate(); publickey publickey = keypair.getpublic();

then save objectoutputstream

now creae objetinputstream file contains key. im doing:

publickey pub = (publickey)preader.readobject();

and exception:

java.lang.classcastexception: sun.security.rsa.rsaprivatecrtkeyimpl cannot cast java.security.publickey.

thanks

obviously must saving private key, not public key.

java exception encryption objectoutputstream

No comments:

Post a Comment