Class HashUtils


  • public final class HashUtils
    extends java.lang.Object
    Hash function for domain names.
    • Constructor Summary

      Constructors 
      Constructor Description
      HashUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String domainAndHash​(java.lang.String domain)  
      static java.lang.String hash​(java.lang.String normalisedDomain, int levels)
      Generate a SHA1 hash and base36 encode it, then return the first 3 chars separated by '.' and prefixed by '.' The parameter is not checked and the caller must supply a correct value.
      static java.lang.String hash1​(java.lang.String normalisedDomain)
      Generate a SHA1 hash and base36 encode it, then return the first char separated by '.' and prefixed by '.' The parameter is not checked and the caller must supply a correct value.
      static java.lang.String hash2​(java.lang.String normalisedDomain)
      Generate a SHA1 hash and base36 encode it, then return the first 2 chars separated by '.' and prefixed by '.' The parameter is not checked and the caller must supply a correct value.
      static java.lang.String hash3​(java.lang.String normalisedDomain)
      Generate a SHA1 hash and base36 encode it, then return the first 3 chars separated by '.' and prefixed by '.' The parameter is not checked and the caller must supply a correct value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HashUtils

        public HashUtils()
    • Method Detail

      • hash

        public static java.lang.String hash​(java.lang.String normalisedDomain,
                                            int levels)
        Generate a SHA1 hash and base36 encode it, then return the first 3 chars separated by '.' and prefixed by '.' The parameter is not checked and the caller must supply a correct value.
        Parameters:
        normalisedDomain - java.lang.String the normalised domain name.
        levels - the number of hash levels
        Returns:
        java.lang.String the hash value.
      • domainAndHash

        public static java.lang.String domainAndHash​(java.lang.String domain)
      • hash1

        public static java.lang.String hash1​(java.lang.String normalisedDomain)
        Generate a SHA1 hash and base36 encode it, then return the first char separated by '.' and prefixed by '.' The parameter is not checked and the caller must supply a correct value.
        Parameters:
        normalisedDomain - java.lang.String the normalised domain name.
        Returns:
        java.lang.String the hash value.
      • hash2

        public static java.lang.String hash2​(java.lang.String normalisedDomain)
        Generate a SHA1 hash and base36 encode it, then return the first 2 chars separated by '.' and prefixed by '.' The parameter is not checked and the caller must supply a correct value.
        Parameters:
        normalisedDomain - java.lang.String the normalised domain name.
        Returns:
        java.lang.String the hash value.
      • hash3

        public static java.lang.String hash3​(java.lang.String normalisedDomain)
        Generate a SHA1 hash and base36 encode it, then return the first 3 chars separated by '.' and prefixed by '.' The parameter is not checked and the caller must supply a correct value.
        Parameters:
        normalisedDomain - java.lang.String the normalised domain name.
        Returns:
        java.lang.String the hash value.