de.hfu.anybeam.networkCore

## Enum EncryptionType

- java.lang.Object
- - java.lang.Enum<EncryptionType>
  - - de.hfu.anybeam.networkCore.EncryptionType

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<EncryptionType>

      public enum EncryptionType
      extends java.lang.Enum<EncryptionType>

  An enum containng all possible encryption types and useful functions.
  Since:
    1.0
  Version:
    1.0
  Author:
    chrwuer

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `AES128`
    `AES256`
    `DES`
    `NONE`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `javax.crypto.Cipher` | `createCipher()` Creates a `Cipher` for this `EncryptionType`.
    `java.lang.String` | `getEncryptionName()` Returns a technical name of this encryption or null if the `EncryptionType` is `NONE`.
    `java.lang.String` | `getHumanEncryptionName()` Returns a human readable name of this encryption or null if the `EncryptionType` is `NONE`.
    `java.lang.String` | `getHumanReadableKey(byte[] key)` Generates a human readable `String` representing the key.
    `int` | `getKeyLength()` Returns the key length for this `EncryptionType` in bit.
    `int` | `getKeyLengthByte()` Returns the key length for this `EncryptionType` in byte.
    `byte[]` | `getRandomSecretKey()` Generates a random secret key using `KeyGenerator` matching the needs of a key this `EncryptionType`.
    `byte[]` | `getSecretKeyFromHumanReadableKey(java.lang.String password)` Generates a key from a human readable `String` created with `getHumanReadableKey(byte[])`
    `byte[]` | `getSecretKeyFromPassword(java.lang.String password)` Generates a random secret key using the password's SHA-1 hash matching the needs of a key this `EncryptionType`.
    `javax.crypto.spec.SecretKeySpec` | `getSecretKeySpec(byte[] rawKeyData)` Creates a `SecretKeySpec` from the given bytes.
    `static EncryptionType` | `valueOf(java.lang.String name)` Returns the enum constant of this type with the specified name.
    `static EncryptionType[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

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

      `compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### DES

          public static final EncryptionType DES

    - #### AES128

          public static final EncryptionType AES128

    - #### AES256

          public static final EncryptionType AES256

    - #### NONE

          public static final EncryptionType NONE

  - ### Method Detail

    - #### values

          public static EncryptionType[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (EncryptionType c : EncryptionType.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static EncryptionType valueOf(java.lang.String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `java.lang.IllegalArgumentException` - if this enum type has no constant with the specified name
        `java.lang.NullPointerException` - if the argument is null

    - #### getHumanEncryptionName

          public java.lang.String getHumanEncryptionName()

      Returns a human readable name of this encryption or null if the `EncryptionType` is `NONE`.
      Returns:
        a human readable name of this encryption or null if the `EncryptionType` is `NONE`

    - #### getEncryptionName

          public java.lang.String getEncryptionName()

      Returns a technical name of this encryption or null if the `EncryptionType` is `NONE`.
      Returns:
        a technical name of this encryption or null if the `EncryptionType` is `NONE`

    - #### getKeyLength

          public int getKeyLength()

      Returns the key length for this `EncryptionType` in bit.
      Returns:
        the key length for this `EncryptionType` in bit or 0 if this `EncryptionType` is `NONE`

    - #### getKeyLengthByte

          public int getKeyLengthByte()

      Returns the key length for this `EncryptionType` in byte.
      Returns:
        the key length for this `EncryptionType` in byte or 0 if this `EncryptionType` is `NONE`

    - #### getRandomSecretKey

          public byte[] getRandomSecretKey()
                                    throws java.lang.Exception

      Generates a random secret key using `KeyGenerator` matching the needs of a key this `EncryptionType`.
      Returns:
        a random secret key using `KeyGenerator` matching the needs of a key this `EncryptionType`
      Throws:
        `java.lang.Exception`

    - #### getSecretKeyFromPassword

          public byte[] getSecretKeyFromPassword(java.lang.String password)

      Generates a random secret key using the password's SHA-1 hash matching the needs of a key this `EncryptionType`.
      Parameters:
        `password` - the password from which the should be created
      Returns:
        a random secret key using the password's SHA-1 hash matching the needs of a key this `EncryptionType`

    - #### createCipher

          public javax.crypto.Cipher createCipher()

      Creates a `Cipher` for this `EncryptionType`.
      Returns:
        a `Cipher` for this `EncryptionType` or null if this `EncryptionType` is `NONE`
      Throws:
        `java.security.NoSuchAlgorithmException`
        `javax.crypto.NoSuchPaddingException`

    - #### getSecretKeySpec

          public javax.crypto.spec.SecretKeySpec getSecretKeySpec(byte[] rawKeyData)

      Creates a `SecretKeySpec` from the given bytes. The length of the given byte array must match the needed length for this `EncryptionType`.
      Parameters:
        `rawKeyData` -
      Returns:
        a `SecretKeySpec` from the given bytes
      See Also:
        `getKeyLengthByte()`, `getKeyLength()`

    - #### getHumanReadableKey

          public java.lang.String getHumanReadableKey(byte[] key)

      Generates a human readable `String` representing the key.
      Parameters:
        `key` - the key that should be converted
      Returns:
        a `String` representing the given key
      See Also:
        `getSecretKeyFromHumanReadableKey(String)`

    - #### getSecretKeyFromHumanReadableKey

          public byte[] getSecretKeyFromHumanReadableKey(java.lang.String password)

      Generates a key from a human readable `String` created with `getHumanReadableKey(byte[])`
      Parameters:
        `password` - the `String` taht should be converted in a key
      Returns:
        the converted key