Class ControlNumberGenerator

    • Field Detail

      • defaultHashLength

        public static final int defaultHashLength
        Default bit lenght of control numbers.
        See Also:
        Constant Field Values
      • defaultNGramLength

        public static final int defaultNGramLength
        Default length of n-grams (2 -> bigrams).
        See Also:
        Constant Field Values
      • defaultNHashFunctions

        public static final int defaultNHashFunctions
        Default number of hash functions.
        See Also:
        Constant Field Values
      • defaultEncoding

        public static final Charset defaultEncoding
        Default encoding to use when transforming input strings to byte sequences (necessery for applying hash functions and encryption).
      • encoding

        protected Charset encoding
    • Method Detail

      • apply

        public ControlNumber apply​(String input)
        Calculate a control number from an input string.
        Specified by:
        apply in interface java.util.function.Function<String,​ControlNumber>
        Parameters:
        input - The character string to encode.
        Returns:
        The resulting control number.
      • getMd5Hash

        protected byte[] getMd5Hash​(String input)
        Get 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 that EncryptedControlNumberGenerator only needs to override these using keyed hash functions.
        Parameters:
        input - The character string to encode.
        Returns:
        The resulting hash.
      • hash

        protected int hash​(byte[] basehash1,
                           byte[] baseHash2,
                           int index)