Code Comments
Programming Forum and web based access to our favorite programming groups.Hi What you need is an Certificate for your
public key. And than do someting like this
to initialize your Cipher.
X509Certificate cert = ...
Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
rsaCipher.init(Cipher.ENCRYPT_MODE, cert);
With that Cipher you can create an CipherIn- or OutputStream.
At the Decryption site of your application you can
initilize your Cihper with the Private-Key.
You should store the private key in an password encrypted
Keystore (ex. JDKPKCS12KeyStore from BouncyCastle)
Hope it helps
But you should think about symetric encryption.
Create a symetric key, encrypt message with "symkey" and
encrypt the "symkey" with the public key and send both
encrypted message and encrypted "symkey".
On the other side decrypt "symkey" and with that decrypted
"symkey" decrypt the message.
If you must ensure that the message comes from the server
you should sign something: either the symkey before encryption
or the complete messagebundle(encrypted message,encrypted key).
Hope it helps even though my bad english
Kind regards.
Sebastian
Rogue Chameleon wrote:
> Hi all
>
> I've managed to generate a public and private key pair, and store them in
> separate files. Now, how do I go about using them to encrypt a file (usin
g
> the public key) and decrypt the file (using the private key)?
>
> tia!
>
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.