FreeTest
Class RSAEncrypt

java.lang.Object
  |
  +--FreeTest.RSAEncrypt

public class RSAEncrypt
extends java.lang.Object

Encrypts/Decrypts data using RSA. (Based on example code included with Cryptix package.) Also includes methods relating to session keys (which then get encrypted with RSA) and the subsequent encryption of data with the session key.

Since:
1.7
Version:
0.4 12 June 2001
Author:
Jason Kitcat, Edwin Woudt

Constructor Summary
RSAEncrypt()
           
 
Method Summary
static java.lang.String blowDecrypt(java.lang.String key, java.lang.String data)
          blowDecrypt uses Blowfish to decrypt data using the session key
static java.lang.String blowEncrypt(java.lang.String key, java.lang.String data)
          blowEncrypt uses Blowfish to encrypt data using the session key
static void init()
          Initialise the SecureRandom for encryption.
static java.lang.String makeSessionKey()
          Using SecureRandom a session key is created.
static java.lang.String privDecrypt(java.lang.String key, java.lang.String data)
          Decrypts supplied hexadecimal-encoded data using private RSA key.
static java.lang.String pubEncrypt(java.lang.String key, java.lang.String data)
          Encrypts the data parameter using the public key and returns as a Hex-encoded string.
static java.lang.String[] splitnDecrypt(java.lang.String key, java.lang.String data)
          splitnDecrypt is a convenience method to split the session key from the data, retrieve the session key and use it to return the data.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSAEncrypt

public RSAEncrypt()
Method Detail

init

public static void init()
                 throws java.lang.Exception
Initialise the SecureRandom for encryption. MUST BE DONE prior to using other methods.

pubEncrypt

public static java.lang.String pubEncrypt(java.lang.String key,
                                          java.lang.String data)
                                   throws java.lang.Exception
Encrypts the data parameter using the public key and returns as a Hex-encoded string.
Parameters:
key - Hex-encoded public RSA key
data - Data to be encrypted

privDecrypt

public static java.lang.String privDecrypt(java.lang.String key,
                                           java.lang.String data)
                                    throws java.lang.Exception
Decrypts supplied hexadecimal-encoded data using private RSA key.
Parameters:
key - Private key
data - Hex-encoded data

makeSessionKey

public static java.lang.String makeSessionKey()
                                       throws java.lang.Exception
Using SecureRandom a session key is created.

blowEncrypt

public static java.lang.String blowEncrypt(java.lang.String key,
                                           java.lang.String data)
                                    throws java.lang.Exception
blowEncrypt uses Blowfish to encrypt data using the session key
Parameters:
key - Hex-encoded key
data - Data to encrypt

blowDecrypt

public static java.lang.String blowDecrypt(java.lang.String key,
                                           java.lang.String data)
                                    throws java.lang.Exception
blowDecrypt uses Blowfish to decrypt data using the session key
Parameters:
key - Hex-encoded key
data - Hex-encoded Data to decrypt

splitnDecrypt

public static java.lang.String[] splitnDecrypt(java.lang.String key,
                                               java.lang.String data)
                                        throws java.lang.Exception
splitnDecrypt is a convenience method to split the session key from the data, retrieve the session key and use it to return the data.
Parameters:
key - Hex-encoded private key
data - Hex-encoded data