public enum EncryptionType extends java.lang.Enum<EncryptionType>
| 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.
|
public static final EncryptionType DES
public static final EncryptionType AES128
public static final EncryptionType AES256
public static final EncryptionType NONE
public static EncryptionType[] values()
for (EncryptionType c : EncryptionType.values()) System.out.println(c);
public static EncryptionType valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant
with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String getHumanEncryptionName()
EncryptionType is NONE.EncryptionType is NONEpublic java.lang.String getEncryptionName()
EncryptionType is NONE.EncryptionType is NONEpublic int getKeyLength()
EncryptionType in bit.EncryptionType in bit or 0 if this EncryptionType is NONEpublic int getKeyLengthByte()
EncryptionType in byte.EncryptionType in byte or 0 if this EncryptionType is NONEpublic byte[] getRandomSecretKey()
throws java.lang.Exception
KeyGenerator matching the needs of a key this EncryptionType.KeyGenerator matching the needs of a key this EncryptionTypejava.lang.Exceptionpublic byte[] getSecretKeyFromPassword(java.lang.String password)
EncryptionType.password - the password from which the should be createdEncryptionTypepublic javax.crypto.Cipher createCipher()
Cipher for this EncryptionType.Cipher for this EncryptionType or null if this EncryptionType is NONEjava.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionpublic javax.crypto.spec.SecretKeySpec getSecretKeySpec(byte[] rawKeyData)
SecretKeySpec from the given bytes. The length of the given byte array must match the needed length for this EncryptionType.rawKeyData - SecretKeySpec from the given bytesgetKeyLengthByte(),
getKeyLength()public java.lang.String getHumanReadableKey(byte[] key)
String representing the key.key - the key that should be convertedString representing the given keygetSecretKeyFromHumanReadableKey(String)public byte[] getSecretKeyFromHumanReadableKey(java.lang.String password)
String created with getHumanReadableKey(byte[])password - the String taht should be converted in a key