Class EncryptedControlNumberGenerator
- java.lang.Object
-
- de.pseudonymisierung.controlnumbers.ControlNumberGenerator
-
- de.pseudonymisierung.controlnumbers.EncryptedControlNumberGenerator
-
- All Implemented Interfaces:
java.util.function.Function<String,ControlNumber>
public class EncryptedControlNumberGenerator extends ControlNumberGenerator
Generator for control numbers using a keyed hash algorithm. Usebuilder(String)to get aEncryptedControlNumberGenerator.Builderinstance, which has methods for setting various parameters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEncryptedControlNumberGenerator.BuilderBuilder for control number generators with keyed hashes.-
Nested classes/interfaces inherited from class de.pseudonymisierung.controlnumbers.ControlNumberGenerator
ControlNumberGenerator.AbstractBuilder<T extends ControlNumberGenerator>
-
-
Field Summary
-
Fields inherited from class de.pseudonymisierung.controlnumbers.ControlNumberGenerator
defaultEncoding, defaultHashLength, defaultNGramLength, defaultNHashFunctions, encoding
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedEncryptedControlNumberGenerator(EncryptedControlNumberGenerator.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EncryptedControlNumberGenerator.Builderbuilder(String passphrase)Get a builder object with methods to set parameters to non-default values and to get the resulting instance ofEncryptedControlNumberGenerator.Stringencrypt(String value)Symmetric encryption of a string using a key based on the configured passphrase.protected byte[]getMd5Hash(String input)Get MD5 hash of a string.protected byte[]getSha1Hash(String input)Get SHA1 hash of a string.-
Methods inherited from class de.pseudonymisierung.controlnumbers.ControlNumberGenerator
apply, builder, hash
-
-
-
-
Constructor Detail
-
EncryptedControlNumberGenerator
protected EncryptedControlNumberGenerator(EncryptedControlNumberGenerator.Builder builder)
-
-
Method Detail
-
getMd5Hash
protected byte[] getMd5Hash(String input)
Description copied from class:ControlNumberGeneratorGet MD5 hash of a string. This is one of the base hash functions from which the desired number of hashes is calculated. The base hashes are defined as protected methods so thatEncryptedControlNumberGeneratoronly needs to override these using keyed hash functions.- Overrides:
getMd5Hashin classControlNumberGenerator- Parameters:
input- The character string to encode.- Returns:
- The resulting hash.
-
getSha1Hash
protected byte[] getSha1Hash(String input)
Description copied from class:ControlNumberGeneratorGet SHA1 hash of a string.- Overrides:
getSha1Hashin classControlNumberGenerator- See Also:
for more information.
-
builder
public static EncryptedControlNumberGenerator.Builder builder(String passphrase)
Get a builder object with methods to set parameters to non-default values and to get the resulting instance ofEncryptedControlNumberGenerator.- Parameters:
passphrase- The passphrase used for encryption. Must be a non-empty string.- Returns:
- A builder for creating instances of
EncryptedControlNumberGenerator.
-
-