# Re: HELP : JCE : How to use KeyPairGenerator with Cipher

Jan Luehe (Jan.Luehe@Eng)
Tue, 9 Jun 1998 12:12:56 -0700 (PDT)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Narendra Patil: "Re: HELP : JCE : How to use KeyPairGenerator with Cipher"
- Previous message: Marianne Mueller: "Re: Help !!"

    Date: Tue, 9 Jun 1998 12:12:56 -0700 (PDT)

    From: Jan Luehe <Jan.Luehe@Eng>

    Subject: Re: HELP : JCE : How to use KeyPairGenerator with Cipher

    To: java-security@web3.javasoft.com, naren@corp.auspex.com

Narendra:

> Can I use the public and private keys obtained from a pair (which is
> generated by a KeyPairGenerator)
> for initializing the Cipher object ?

Yes, of course.

As you may have noted, the Cipher.init() methods take a
"java.security.Key" object, which could be an instance of
"java.security.PublicKey", "java.security.PrivateKey",
or "javax.crypto.SecretKey".

> Basically I would like to encrypt the data using the public key (from the
> pair) and decrypt
> using the private key.
>
> Is this possible ? How can I do this ?

Yes, this is possible.

You create your key pair (e.g., for RSA), then use its
public or private component to intitialize the Cipher
object, using one of the Cipher.init() methods.

Jan

- Next message: Narendra Patil: "Re: HELP : JCE : How to use KeyPairGenerator with Cipher"
- Previous message: Marianne Mueller: "Re: Help !!"