public static DescriptorDigest fromHash(String hash) throws DigestException {
    if (!hash.matches(HASH_REGEX)) {
      throw new DigestException("Invalid hash: " + hash);
    }

    return new DescriptorDigest(hash);
  }
Creates a new instance from a valid hash string.

@param hash the hash to generate the {@link DescriptorDigest} from
@return a new {@link DescriptorDigest} created from the hash
@throws DigestException if the hash is invalid
jib-core/src/main/java/com/google/cloud/tools/jib/api/DescriptorDigest.java