es.vocali.util
Class AESCrypt

java.lang.Object
  extended by es.vocali.util.AESCrypt

public class AESCrypt
extends java.lang.Object

This class provides methods to encrypt and decrypt files using aescrypt file format, version 1 or 2.

Requires Java 6 and Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.

Thread-safety and sharing: this class is not thread-safe.
AESCrypt objects can be used as Commands (create, use once and dispose), or reused to perform multiple operations (not concurrently though).

Author:
VĂ³cali Sistemas Inteligentes

Constructor Summary
AESCrypt(boolean debug, java.lang.String password)
          Builds an object to encrypt or decrypt files with the given password.
AESCrypt(java.lang.String password)
          Builds an object to encrypt or decrypt files with the given password.
 
Method Summary
 void decrypt(java.lang.String fromPath, java.lang.String toPath)
          The file at fromPath is decrypted and saved at toPath location.
 void encrypt(int version, java.lang.String fromPath, java.lang.String toPath)
          The file at fromPath is encrypted and saved at toPath location.
static void main(java.lang.String[] args)
           
 void setPassword(java.lang.String password)
          Changes the password this object uses to encrypt and decrypt.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AESCrypt

public AESCrypt(java.lang.String password)
         throws java.security.GeneralSecurityException,
                java.io.UnsupportedEncodingException
Builds an object to encrypt or decrypt files with the given password.

Throws:
java.security.GeneralSecurityException - if the platform does not support the required cryptographic methods.
java.io.UnsupportedEncodingException - if UTF-16 encoding is not supported.

AESCrypt

public AESCrypt(boolean debug,
                java.lang.String password)
         throws java.security.GeneralSecurityException,
                java.io.UnsupportedEncodingException
Builds an object to encrypt or decrypt files with the given password.

Throws:
java.security.GeneralSecurityException - if the platform does not support the required cryptographic methods.
java.io.UnsupportedEncodingException - if UTF-16 encoding is not supported.
Method Detail

setPassword

public void setPassword(java.lang.String password)
                 throws java.io.UnsupportedEncodingException
Changes the password this object uses to encrypt and decrypt.

Throws:
java.io.UnsupportedEncodingException - if UTF-16 encoding is not supported.

encrypt

public void encrypt(int version,
                    java.lang.String fromPath,
                    java.lang.String toPath)
             throws java.io.IOException,
                    java.security.GeneralSecurityException
The file at fromPath is encrypted and saved at toPath location.

version can be either 1 or 2.

Throws:
java.io.IOException - when there are I/O errors.
java.security.GeneralSecurityException - if the platform does not support the required cryptographic methods.

decrypt

public void decrypt(java.lang.String fromPath,
                    java.lang.String toPath)
             throws java.io.IOException,
                    java.security.GeneralSecurityException
The file at fromPath is decrypted and saved at toPath location.

Source file can be encrypted using version 1 or 2 of aescrypt.

Throws:
java.io.IOException - when there are I/O errors.
java.security.GeneralSecurityException - if the platform does not support the required cryptographic methods.

main

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