String representation of an object for hashing
976597
def obj2str(obj):
    """"""
    if isinstance(obj, str_types):
        return obj.encode("utf-8")
    elif isinstance(obj, pathlib.Path):
        return obj2str(str(obj))
    elif isinstance(obj, (bool, int, float)):
        return str(obj).encode("utf-8")
    elif obj is None:
        return b"none"
    elif isinstance(obj, np.ndarray):
        return obj.tostring()
    elif isinstance(obj, tuple):
        return obj2str(list(obj))
    elif isinstance(obj, list):
        return b"".join(obj2str(o) for o in obj)
    elif isinstance(obj, dict):
        return obj2str(list(obj.items()))
    elif hasattr(obj, "identifier"):
        return obj2str(obj.identifier)
    elif isinstance(obj, h5py.Dataset):
        return obj2str(obj[0])
    else:
        raise ValueError("No rule to convert object '{}' to string.".
                         format(obj.__class__))
971628
function objectToQueryString(obj) {
        var str = [];
        for (var p in obj) {
            if (obj.hasOwnProperty(p)) {
                str.push(p + '=' + obj[p]);
            }
        }
        return str.join('&');
    }
1291878
def hashid_arr(arr, label='arr', hashlen=16):
    
    hashstr = hash_data(arr)[0:hashlen]
    if isinstance(arr, (list, tuple)):
        shapestr = len(arr)
    else:
        shapestr = ','.join(list(map(str, arr.shape)))
    hashid = '{}-{}-{}'.format(label, shapestr, hashstr)
    return hashid
191321
def _hash(number, alphabet):
    """"""
    hashed = ''
    len_alphabet = len(alphabet)
    while True:
        hashed = alphabet[number % len_alphabet] + hashed
        number //= len_alphabet
        if not number:
            return hashed
874492
def hash(self, value):
        
        if is_iterable(value):
            value = tuple(to_bytestring(v) for v in value)
        return hashlib.md5(six.b(':').join(value)).hexdigest()
1092125
def hash_func(name):
    
    ret = 0
    for char in name:
        ret = ((ret << 5) + ret + ord(char)) & 0xffffffff
    return hex(ret)
443566
def jsonhash(obj, root=True, exclude=None, hash_func=_jsonhash_sha1):
    '''
    
    '''
    if isinstance(obj, Mapping):
        # assumption: using in against set() is faster than in against list()
        if root and exclude:
            obj = {k: v for k, v in obj.iteritems() if k not in exclude}
        # frozenset's don't guarantee order; use sorted tuples
        # which means different python interpreters can return
        # back frozensets with different hash values even when
        # the content of the object is exactly the same
        result = sorted(
            (k, jsonhash(v, False)) for k, v in obj.iteritems())
    elif isinstance(obj, list):
        # FIXME: should lists be sorted for consistent hashes?
        # when the object is the same, just different list order?
        result = tuple(jsonhash(e, False) for e in obj)
    else:
        result = obj
    if root:
        result = unicode(hash_func(result))
    return result
870079
def string_hash(hash)
      hash.map { |k, v| [k.to_s, v.to_s] }.to_h
    end
1004696
function objectToQueryString (obj) {
    let qs = reduce(obj, (result, value, key) => {
        if (!isNull(value) && !isUndefined(value)) {
            if (isArray(value)) {
                result += reduce(value, (result1, value1) => {
                    if (!isNull(value1) && !isUndefined(value1)) {
                        result1 += key + '=' + value1 + '&';
                        return result1
                    } else {
                        return result1;
                    }
                }, '')
            } else {
                result += key + '=' + value + '&';
            }
            return result;
        } else {
            return result
        }
    }, '').slice(0, -1);
    return qs;
}
73203
def hash_values(values, alg="md5"):
    """"""
    import hashlib
    if alg not in ['md5', 'sha1', 'sha256']:
        raise Exception("Invalid hashing algorithm!")

    hasher = getattr(hashlib, alg)
    if type(values) == str:
        output = hasher(values).hexdigest()
    elif type(values) == list:
        output = list()
        for item in values:
            output.append(hasher(item).hexdigest())
    return output
530368
def hash(self, val):
        """"""

        if not isinstance(val, bytes):
            raise _TypeError("val", "bytes", val)

        rv = self.compute(val)

        if not isinstance(val, bytes):
            raise _TypeError("val", "bytes", rv)

        return rv
997663
private int _hashCode(Object values) {
        int valueHash = 0;
        if (values instanceof Object[])
            valueHash = Arrays.deepHashCode((Object[]) values);
        else if (values instanceof byte[])
            valueHash = Arrays.hashCode((byte[]) values);
        else if (values instanceof short[])
            valueHash = Arrays.hashCode((short[]) values);
        else if (values instanceof int[])
            valueHash = Arrays.hashCode((int[]) values);
        else if (values instanceof long[])
            valueHash = Arrays.hashCode((long[]) values);
        else if (values instanceof char[])
            valueHash = Arrays.hashCode((char[]) values);
        else if (values instanceof float[])
            valueHash = Arrays.hashCode((float[]) values);
        else if (values instanceof double[])
            valueHash = Arrays.hashCode((double[]) values);
        else if (values instanceof boolean[])
            valueHash = Arrays.hashCode((boolean[]) values);
        else if (values != null)
            valueHash = values.hashCode();
        return valueHash;
    }
825503
function getHash(str, algorithm) {
  algorithm = algorithm || 'md5';
  var hash = crypto.createHash(algorithm);
  hash.end(str);
  return hash.read();
}
486614
private static int normalizedHash(int hash, String s) {
    int nextHash = 0;
    for (int index = 0; index < s.length(); index++) {
      char ch = s.charAt(index);
      nextHash = 31 * nextHash + ch;
      if (ch == '%') {
        // hash next 2 characters
        index++;
        nextHash = 31 * nextHash + URIUtils.toLower(s.charAt(index));
        index++;
        nextHash = 31 * nextHash + URIUtils.toLower(s.charAt(index));
      }
    }
    // similar to Arrays.hashCode
    return hash * 31 + nextHash;
  }
119259
def to_hash arr
      return {}   if arr.nil?
      return arr  if arr.kind_of?(Hash)
      arr = [ arr.to_sym ]  unless arr.kind_of?(Array)
      ret = {}
      arr.each { |key| ret[key.to_sym] = {} }
      ret
    end
644514
def hasher(data, algos=ALGOS):
    """"""
    try:
        data = data.encode()
    except Exception:
        pass

    result = {}

    for algo in sorted(hashlib.algorithms_available):
        if algo in algos:
            h = hashlib.new(algo)
            h.update(data)
            result[algo] = h.hexdigest()

    return result
1220499
def getBytesForString(self, u):
        
        h = hash(u)
        s = self._unicodes.get(h, None)

        if s is not None:
            return s

        s = self._unicodes[h] = u.encode('utf-8')

        return s