Class EncryptionKey
java.lang.Object
com.norconex.commons.lang.encrypt.EncryptionKey
- All Implemented Interfaces:
Serializable
Pointer to the an encryption key, or the encryption key itself. An encryption key can be seen as equivalent to a secret key, passphrase or password.
- Since:
- 1.9.0
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEncryptionKey(String value) Creates a new encryption key where the value is the actual key.EncryptionKey(String value, int size) Creates a new encryption key where the value is the actual key, and the number of key bits to generate is the size.EncryptionKey(String value, EncryptionKey.Source source) Creates a new reference to an encryption key.EncryptionKey(String value, EncryptionKey.Source source, int size) Creates a new reference to an encryption key. -
Method Summary
Modifier and TypeMethodDescriptionbooleanintgetSize()Gets the size in bits of the encryption key.A pointer to the encryption key location, returned bygetValue().getValue()The actual encryption key (when "source" is KEY) or a reference to the encryption key location (when "source" is something other than KEY).inthashCode()resolve()Locate the key according to its value type and return it.toString()
-
Field Details
-
DEFAULT_KEY_SIZE
public static final int DEFAULT_KEY_SIZE- See Also:
-
-
Constructor Details
-
EncryptionKey
Creates a new reference to an encryption key. The reference can either be the key itself, or a pointer to a file or environment variable containing the key (as defined by the supplied value type). The actual value can be any sort of string, and it is converted to an encryption key of length size using cryptographic algorithms. If the size is specified, it must be supported by your version of Java.- Parameters:
value- the encryption keysource- the type of valuesize- the size in bits of the encryption key
-
EncryptionKey
Creates a new reference to an encryption key. The reference can either be the key itself, or a pointer to a file or environment variable containing the key (as defined by the supplied value type).- Parameters:
value- the encryption keysource- the type of value
-
EncryptionKey
Creates a new encryption key where the value is the actual key, and the number of key bits to generate is the size.- Parameters:
value- the encrption keysize- the encryption key size in bits
-
EncryptionKey
Creates a new encryption key where the value is the actual key.- Parameters:
value- the encryption key
-
-
Method Details
-
getValue
The actual encryption key (when "source" is KEY) or a reference to the encryption key location (when "source" is something other than KEY).- Returns:
- the encryption key or reference it
-
getSource
A pointer to the encryption key location, returned bygetValue().- Returns:
- key source
-
getSize
public int getSize()Gets the size in bits of the encryption key. Default is 256.- Returns:
- size in bits of the encryption key
- Since:
- 1.15.0
-
resolve
Locate the key according to its value type and return it. This method will always resolve the value each type it is invoked and never caches the key, unless the key value specified at construction time is the actual key.- Returns:
- encryption key or
nullif the key does not exist for the specified type
-
toString
-
equals
-
hashCode
public int hashCode()
-