net.sourceforge.jcetaglib.lib
Class Asymmetric

java.lang.Object
  extended bynet.sourceforge.jcetaglib.lib.Asymmetric

public class Asymmetric
extends java.lang.Object

Asymmetric encryption & decryption routines with BouncyCastle JCE provider

Version:
$Id: Asymmetric.java,v 1.3 2004/04/15 07:28:24 hamgert Exp $
Author:
Gert Van Ham, hamgert@users.sourceforge.net, http://jcetaglib.sourceforge.net

Constructor Summary
Asymmetric()
           
 
Method Summary
static void decrypt(java.io.InputStream is, java.io.DataOutputStream daos, java.security.PrivateKey decryptKey, int bufferlength)
          Decrypts an inputstream, encrypted with an RSA public key (from X.509), with the corresponding private key
static java.lang.StringBuffer decrypt(java.lang.StringBuffer text, java.security.PrivateKey decryptKey)
          decrypts text with a private RSA key (from a X.509 certificate)
static void encrypt(java.io.InputStream is, java.io.DataOutputStream daos, java.security.PublicKey encryptKey, int bufferlength)
          Encrypts an inputstream with a public RSA key (from a X.509 certificate) This result can only be decrypted with the corresponding private key
static java.lang.StringBuffer encrypt(java.lang.StringBuffer text, java.security.PublicKey encryptKey)
          Encrypts text with a public RSA key (from a X.509 certificate)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Asymmetric

public Asymmetric()
Method Detail

encrypt

public static java.lang.StringBuffer encrypt(java.lang.StringBuffer text,
                                             java.security.PublicKey encryptKey)
                                      throws CryptoException
Encrypts text with a public RSA key (from a X.509 certificate)

Parameters:
text - the text to encrypt
encryptKey - the public encryption key
Returns:
the encrypted text in BASE64 format
Throws:
CryptoException - for encryption errors

encrypt

public static void encrypt(java.io.InputStream is,
                           java.io.DataOutputStream daos,
                           java.security.PublicKey encryptKey,
                           int bufferlength)
                    throws CryptoException,
                           java.io.IOException
Encrypts an inputstream with a public RSA key (from a X.509 certificate) This result can only be decrypted with the corresponding private key

Parameters:
is - the inputstream to encrypt
daos - returns ciphered outputstream
encryptKey - the public encryption key
Throws:
java.io.IOException - I/O errors
CryptoException - for all encryption errors

decrypt

public static java.lang.StringBuffer decrypt(java.lang.StringBuffer text,
                                             java.security.PrivateKey decryptKey)
                                      throws CryptoException
decrypts text with a private RSA key (from a X.509 certificate)

Parameters:
text - the text to decrypt
decryptKey - the private key
Returns:
the encrypted text in BASE64 format
Throws:
CryptoException - for encryption errors

decrypt

public static void decrypt(java.io.InputStream is,
                           java.io.DataOutputStream daos,
                           java.security.PrivateKey decryptKey,
                           int bufferlength)
                    throws CryptoException,
                           java.io.IOException
Decrypts an inputstream, encrypted with an RSA public key (from X.509), with the corresponding private key

Parameters:
is - the inputstream to decrypt
daos - returns deciphered outputstream
decryptKey - the private key
Throws:
java.io.IOException - I/O errors
CryptoException - for all encryption errors