com.eu.miscedautils.CommonUtils
Class FileEncryption

java.lang.Object
  extended by com.eu.miscedautils.CommonUtils.FileEncryption

public class FileEncryption
extends java.lang.Object

Utility class for encrypting/decrypting files.

Author:
Michael Lones

Field Summary
static int AES_Key_Size
           
 
Constructor Summary
FileEncryption()
          Constructor: creates ciphers
 
Method Summary
 void decrypt(java.io.File in, java.io.File out)
          Decrypts and then copies the contents of a given file.
 void encrypt(java.io.File in, java.io.File out)
          Encrypts and then copies the contents of a given file.
 void loadKey(java.io.File in, java.io.File privateKeyFile)
          Decrypts an AES key from a file using an RSA private key
 void makeKey()
          Creates a new AES key
 void saveKey(java.io.File out, java.io.File publicKeyFile)
          Encrypts the AES key to a file using an RSA public key
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AES_Key_Size

public static final int AES_Key_Size
See Also:
Constant Field Values
Constructor Detail

FileEncryption

public FileEncryption()
               throws java.security.GeneralSecurityException
Constructor: creates ciphers

Throws:
java.security.GeneralSecurityException
Method Detail

makeKey

public void makeKey()
             throws java.security.NoSuchAlgorithmException
Creates a new AES key

Throws:
java.security.NoSuchAlgorithmException

loadKey

public void loadKey(java.io.File in,
                    java.io.File privateKeyFile)
             throws java.security.GeneralSecurityException,
                    java.io.IOException
Decrypts an AES key from a file using an RSA private key

Throws:
java.security.GeneralSecurityException
java.io.IOException

saveKey

public void saveKey(java.io.File out,
                    java.io.File publicKeyFile)
             throws java.io.IOException,
                    java.security.GeneralSecurityException
Encrypts the AES key to a file using an RSA public key

Throws:
java.io.IOException
java.security.GeneralSecurityException

encrypt

public void encrypt(java.io.File in,
                    java.io.File out)
             throws java.io.IOException,
                    java.security.InvalidKeyException
Encrypts and then copies the contents of a given file.

Throws:
java.io.IOException
java.security.InvalidKeyException

decrypt

public void decrypt(java.io.File in,
                    java.io.File out)
             throws java.io.IOException,
                    java.security.InvalidKeyException
Decrypts and then copies the contents of a given file.

Throws:
java.io.IOException
java.security.InvalidKeyException