org.itr_rescue.dataGuard.encryption.asymmetric
Class Encryptor

java.lang.Object
  extended by org.itr_rescue.dataGuard.encryption.asymmetric.Encryptor

public class Encryptor
extends java.lang.Object


Field Summary
static boolean EXISTING
           
static boolean NEW
           
 
Constructor Summary
Encryptor(java.lang.String password, java.lang.String XMLKey)
           
 
Method Summary
 byte[] decodeBase64(java.lang.String encoded)
           
 java.security.Key decodeRSAKey(java.lang.String encodedKey)
           
 byte[] decrypt(java.lang.String data)
           
 byte[] decryptFile(byte[] file, java.lang.String encryptedKey)
          Use this function to decrypt a file.
 byte[] decryptPassword(byte[] file)
           
 java.lang.String decryptString(byte[] file)
           
 java.lang.String decryptString(byte[] file, java.lang.String key)
           
 byte[] decryptXML(byte[] file)
           
 java.lang.String encodeBase64(byte[] file)
           
 java.lang.String encrypt(byte[] file)
           
 byte[] encryptFile(byte[] file, boolean isNew)
           
 java.lang.String encryptPassword(java.lang.String password)
           
 java.lang.String encryptPublicKey(javax.crypto.SecretKey randomKey, byte[] publicKey)
           
 byte[] encryptString(java.lang.String s)
           
 byte[] encryptString(java.lang.String s, boolean isNew)
           
 byte[] encryptXML(byte[] file)
           
 byte[] getDecodedKey()
           
 java.lang.String getEncodedPublicKey()
           
 java.lang.String getKey()
          Use this function to retrieve the random key that was generated to encrypt a file.
 javax.crypto.SecretKey getOnlyKey()
           
 java.security.Key getPrivateKey()
           
 java.security.Key getPublicKey()
          Use this function to retrieve the RSA public key generated by the master password.
 java.lang.String getXMLKey()
           
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW

public static boolean NEW

EXISTING

public static boolean EXISTING
Constructor Detail

Encryptor

public Encryptor(java.lang.String password,
                 java.lang.String XMLKey)
Method Detail

main

public static void main(java.lang.String[] args)

encrypt

public java.lang.String encrypt(byte[] file)

decrypt

public byte[] decrypt(java.lang.String data)

encryptPassword

public java.lang.String encryptPassword(java.lang.String password)

decryptPassword

public byte[] decryptPassword(byte[] file)

encryptFile

public byte[] encryptFile(byte[] file,
                          boolean isNew)

decryptFile

public byte[] decryptFile(byte[] file,
                          java.lang.String encryptedKey)
Use this function to decrypt a file. The random key is stored in the database along with the file. The key is encrypted using the password (thus, safe from prying eyes) and Base64 encoded to avoid syntax problems when inserted into the database.


getKey

public java.lang.String getKey()
Use this function to retrieve the random key that was generated to encrypt a file. Note that the key is encoded in Base64 to avoid MySQL syntax errors when inserting into the database.


getOnlyKey

public javax.crypto.SecretKey getOnlyKey()

encryptPublicKey

public java.lang.String encryptPublicKey(javax.crypto.SecretKey randomKey,
                                         byte[] publicKey)

getDecodedKey

public byte[] getDecodedKey()

encodeBase64

public java.lang.String encodeBase64(byte[] file)

decodeBase64

public byte[] decodeBase64(java.lang.String encoded)

getPublicKey

public java.security.Key getPublicKey()
Use this function to retrieve the RSA public key generated by the master password. Note that this will be encoded in Base64 to avoid any MySQL syntax errors when inserting into the database.


getEncodedPublicKey

public java.lang.String getEncodedPublicKey()

getPrivateKey

public java.security.Key getPrivateKey()

decodeRSAKey

public java.security.Key decodeRSAKey(java.lang.String encodedKey)

encryptXML

public byte[] encryptXML(byte[] file)

decryptXML

public byte[] decryptXML(byte[] file)

getXMLKey

public java.lang.String getXMLKey()

encryptString

public byte[] encryptString(java.lang.String s)

decryptString

public java.lang.String decryptString(byte[] file)

encryptString

public byte[] encryptString(java.lang.String s,
                            boolean isNew)

decryptString

public java.lang.String decryptString(byte[] file,
                                      java.lang.String key)