Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: [Newbie] How to use public key to encrypt and private key to
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!
>

Report this thread to moderator Post Follow-up to this message
Old Post
Sebastian Hentschel
12-15-04 09:00 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Security archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:32 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.