org.licas.security

## Class Encryption

- java.lang.Object
- - org.licas.security.Encryption

-     public class Encryption
      extends java.lang.Object

  This can encrypt and decrypt a string message using the 'AES' algorithm. Note that encryption cannot be done in parts and concatenated together. https://stackoverflow.com/questions/7762771/how-do-i-encrypt-decrypt-a-string-with-another-string-as-a-password
  Author:
    Kieran Greer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Encryption()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `decrypt(java.lang.String toDecrypt, java.security.Key key)` Decrypt a string using a strong aes algorithm.
    `java.lang.String` | `encrypt(java.lang.String toEncrypt, java.security.Key key)` Encrypt a string using a strong aes algorithm.
    `java.security.Key` | `generateKey()` Generate a unique key to use as the basis for some encryption.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Encryption

          public Encryption()

  - ### Method Detail

    - #### encrypt

          public java.lang.String encrypt(java.lang.String toEncrypt,
                                          java.security.Key key)
                                   throws java.lang.Exception

      Encrypt a string using a strong aes algorithm. The returned string is also base64 encoded, so use decrypt to reverse the encryption.
      Parameters:
        `toEncrypt` - the string to encrypt.
        `key` - the encryption key.
      Returns:
        the encrypted byte string.
      Throws:
        `java.lang.Exception` - any error.

    - #### decrypt

          public java.lang.String decrypt(java.lang.String toDecrypt,
                                          java.security.Key key)
                                   throws java.lang.Exception

      Decrypt a string using a strong aes algorithm.
      Parameters:
        `toDecrypt` - the string to decrypt.
        `key` - the encryption key.
      Returns:
        the encrypted string.
      Throws:
        `java.lang.Exception` - any error.

    - #### generateKey

          public java.security.Key generateKey()
                                        throws java.lang.Exception

      Generate a unique key to use as the basis for some encryption.
      Returns:
        the encryption key.
      Throws:
        `java.lang.Exception` - any error.