Class Sha1HashCode


  • public final class Sha1HashCode
    extends Object
    A typesafe representation of a SHA-1 hash. It is safer to pass this around than a byte[].
    • Method Detail

      • fromBytes

        public static Sha1HashCode fromBytes​(byte[] bytes)
        Clones the specified bytes and uses the clone to create a new Sha1HashCode.
      • fromHashCode

        public static Sha1HashCode fromHashCode​(com.google.common.hash.HashCode hashCode)
      • update

        public com.google.common.hash.Hasher update​(com.google.common.hash.Hasher hasher)
        Updates the specified Hasher by putting the 20 bytes of this SHA-1 to it in order.
        Returns:
        The specified Hasher.
      • asHashCode

        public com.google.common.hash.HashCode asHashCode()
        This method should be used sparingly as we are trying to favor Sha1HashCode over HashCode, where appropriate. Currently, the FileHashCache API is written in terms of HashCode, so conversions are common. As we migrate it to use Sha1HashCode, this method should become unnecessary.
        Returns:
        a HashCode with an equivalent value
      • getHash

        public String getHash()
        Returns:
        the hash as a 40-character string from the alphabet [a-f0-9].
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object