A hashing method that changes a string (like a URL) into a hash suitable
for using as a disk filename.
320625
public String hash(String key) {
        if (digester != null) {
            byte[] bytes = digester.digest(key.getBytes());
            return bytesToHexString(bytes);
        } else {
            return Integer.toHexString(key.hashCode());
        }
    }
247002
def hashed(source_filename, prepared_options, thumbnail_extension, **kwargs):
    
    parts = ':'.join([source_filename] + prepared_options)
    short_sha = hashlib.sha1(parts.encode('utf-8')).digest()
    short_hash = base64.urlsafe_b64encode(short_sha[:9]).decode('utf-8')
    return '.'.join([short_hash, thumbnail_extension])
488932
function hash(str, algo, encoding) {
  return crypto
    .createHash(algo || 'sha1')
    .update(str)
    .digest(encoding || 'hex');
}
1138125
function hash (str) {
  return crypto
    .createHash('sha1')
    .update(str, 'ascii')
    .digest('base64')
    .replace(PLUS_GLOBAL_REGEXP, '-')
    .replace(SLASH_GLOBAL_REGEXP, '_')
    .replace(EQUAL_GLOBAL_REGEXP, '')
}
1300987
def json_file_to_hash(filename)
      raise "File #{filename} not found" unless File.exist?(filename)

      file = File.read(filename)
      begin
        FFI_Yajl::Parser.parse(file)
      rescue FFI_Yajl::ParseError
        raise "File #{filename} does not appear to contain valid JSON"
      end
    end
23767
def _string_hash(s):
    """"""
    h = 5381
    for c in s:
        h = h * 33 + ord(c)
    return h
874667
def get_storage_hash(storage):
    
    # If storage is wrapped in a lazy object we need to get the real thing.
    if isinstance(storage, LazyObject):
        if storage._wrapped is None:
            storage._setup()
        storage = storage._wrapped
    if not isinstance(storage, six.string_types):
        storage_cls = storage.__class__
        storage = '%s.%s' % (storage_cls.__module__, storage_cls.__name__)
    return hashlib.md5(storage.encode('utf8')).hexdigest()
786326
def file_hash(path, hash_type='md5'):
    
    if os.path.exists(path):
        h = getattr(hashlib, hash_type)()
        with open(path, 'rb') as source:
            h.update(source.read())
        return h.hexdigest()
    else:
        return None
1213887
def to_hash
            index_hash = Hash.new
            index_hash["json_claz"] = self.class.name
            index_hash["id"] = id
            index_hash["account_id"] = account_id
            index_hash["asm_id"] = asm_id
            index_hash["org_id"] = org_id
            index_hash["tosca_type"] = tosca_type
            index_hash["inputs"] = inputs
            index_hash["outputs"] = outputs
            index_hash["name"] = name
            index_hash["status"] = status
            index_hash["disk_id"] = disk_id
            index_hash["snap_id"] = snap_id
            index_hash["created_at"] = created_at
            index_hash["updated_at"] = updated_at
            index_hash["some_msg"] = some_msg
            index_hash
        end
1020003
def _hash(self, hash_name):
        
        m = hashlib.new(hash_name)
        for chunk in self.chunks(8192, mode="rb"):
            m.update(chunk)
        return m
790951
def _dhash(self, params):
        """"""
        m = hashlib.new('md5')
        m.update(self.hash.encode('utf-8'))
        for key in sorted(params.keys()):
            h_string = ('%s-%s' % (key, params[key])).encode('utf-8')
            m.update(h_string)
        return m.hexdigest()
802005
def _hashfile(self,filename,blocksize=65536):
        """"""
        logger.debug("Hashing file %s"%(filename))
        hasher=hashlib.sha256()
        afile=open(filename,'rb')
        buf=afile.read(blocksize)
        while len(buf) > 0:
            hasher.update(buf)
            buf = afile.read(blocksize)
        return hasher.hexdigest()
1090473
def hash_file(filepath: str) -> str:
    """"""
    md5 = hashlib.md5()
    acc_hash(filepath, md5)
    return md5.hexdigest()
772380
def directory_content_with_hash(directory):
    
    output = {}
    for root, _, filenames in os.walk(directory):
        for filename in filenames:
            p = os.path.join(root, filename)
            file_stat = os.stat(p)
            with open(p, 'rb') as f:
                output[os.path.relpath(p, directory)] = (hash_file(f), file_stat.st_mode)
    return output
364737
def digest(dirname, glob=None):
    
    md5 = hashlib.md5()
    if glob is None:
        fnames = [fname for _, fname in list_files(Path(dirname))]
        for fname in sorted(fnames):
            fname = os.path.join(dirname, fname)
            md5.update(open(fname, 'rb').read())
    else:
        fnames = Path(dirname).glob(glob)
        for fname in sorted(fnames):
            md5.update(fname.open('rb').read())
    return md5.hexdigest()
1076331
private static String toSHA256String(String str) throws UnsupportedEncodingException {
    // Normalize the string before hashing.
    byte[] hash = digest.digest(toNormalizedString(str).getBytes("UTF-8"));
    StringBuilder result = new StringBuilder();
    for (byte b : hash) {
      result.append(String.format("%02x", b));
    }

    return result.toString();
  }
71443
@SuppressWarnings("unused")
    private Map<String, String> hashFiles(String... fileNames) {
        Map<String, String> hashes = new HashMap<String, String>();
        for (int i = 0; i < fileNames.length; i++) {
            String hash = hashURL(fileNames[i]);
            hashes.put(fileNames[i], hash);
        }
        return hashes;
    }