Hash a string using MPQ's hash function.
6775
def _hash(self, string, hash_type):
        """"""
        hash_types = {
            'TABLE_OFFSET': 0,
            'HASH_A': 1,
            'HASH_B': 2,
            'TABLE': 3
        }
        seed1 = 0x7FED7FED
        seed2 = 0xEEEEEEEE

        for ch in string.upper():
            if not isinstance(ch, int): ch = ord(ch)
            value = self.encryption_table[(hash_types[hash_type] << 8) + ch]
            seed1 = (value ^ (seed1 + seed2)) & 0xFFFFFFFF
            seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3 & 0xFFFFFFFF

        return seed1
1060511
private String hash(String dataId)
   {
      try
      {
         MessageDigest digest = MessageDigest.getInstance(hashAlgorithm);
         digest.update(dataId.getBytes("UTF-8"));
         return new BigInteger(1, digest.digest()).toString(32);
      }
      catch (NumberFormatException e)
      {
         throw new RuntimeException("Could not generate the hash code of '" + dataId + "' with the algorithm '"
            + hashAlgorithm + "'", e);
      }
      catch (UnsupportedEncodingException e)
      {
         throw new RuntimeException("Could not generate the hash code of '" + dataId + "' with the algorithm '"
            + hashAlgorithm + "'", e);
      }
      catch (NoSuchAlgorithmException e)
      {
         throw new RuntimeException("Could not generate the hash code of '" + dataId + "' with the algorithm '"
            + hashAlgorithm + "'", e);
      }
   }
237397
def hashitem(item):
    '''
    
    '''
    norm = normitem(item)
    byts = s_msgpack.en(norm)
    return hashlib.md5(byts).hexdigest()
825503
function getHash(str, algorithm) {
  algorithm = algorithm || 'md5';
  var hash = crypto.createHash(algorithm);
  hash.end(str);
  return hash.read();
}
856888
def _hash_internal(method, salt, password):
    
    if method == 'plain':
        return password, method

    if isinstance(password, text_type):
        password = password.encode('utf-8')

    if method.startswith('pbkdf2:'):
        args = method[7:].split(':')
        if len(args) not in (1, 2):
            raise ValueError('Invalid number of arguments for PBKDF2')
        method = args.pop(0)
        iterations = args and int(args[0] or 0) or DEFAULT_PBKDF2_ITERATIONS
        is_pbkdf2 = True
        actual_method = 'pbkdf2:%s:%d' % (method, iterations)
    else:
        is_pbkdf2 = False
        actual_method = method

    hash_func = _hash_funcs.get(method)
    if hash_func is None:
        raise TypeError('invalid method %r' % method)

    if is_pbkdf2:
        if not salt:
            raise ValueError('Salt is required for PBKDF2')
        rv = pbkdf2_hex(password, salt, iterations,
                        hashfunc=hash_func)
    elif salt:
        if isinstance(salt, text_type):
            salt = salt.encode('utf-8')
        rv = hmac.HMAC(salt, password, hash_func).hexdigest()
    else:
        h = hash_func()
        h.update(password)
        rv = h.hexdigest()
    return rv, actual_method
715119
def hash_args(*args, **kwargs):
    """"""
    arg_string = '_'.join([str(arg) for arg in args])
    kwarg_string = '_'.join([str(key) + '=' + str(value)
                             for key, value in iteritems(kwargs)])
    combined = ':'.join([arg_string, kwarg_string])

    hasher = md5()
    hasher.update(b(combined))
    return hasher.hexdigest()
1178179
def std_hash(word, salt):
    """"""

    try:
        password = word.encode('utf-8')
    except UnicodeDecodeError:
        password = word

    word_hash = sha512(password)
    word_hash.update(salt)
    hex_hash = word_hash.hexdigest()

    return hex_hash
1063285
def md5sum( string ):
    
    h = hashlib.new( 'md5' )
    h.update( string.encode( 'utf-8' ) )
    return h.hexdigest()
66689
function hash(str, prime) {
            utils.dassert(isValue(str));
            var hash = 5381;
            if(isValue(prime)) {
                hash = prime;
            }
            var len = str.length;
            for(var i = 0; i < len; i++) {
                hash = ((hash << 5) - hash) + str.charCodeAt(i);
                hash = hash & hash;
            }
            return hash;
        }
625818
def from_string(cls, hash, **context):
        """"""
        salt, checksum = parse_mc2(hash, cls.ident, handler=cls)

        return cls(salt=salt, checksum=checksum)
1035120
public static String encodeHash(LatLong p, int length) {
        return encodeHash(p.getLat(), p.getLon(), length);
    }
78817
function hashPw(req, password)
{
	if (password) {
		return req.app.jsl.crypto.createHash('sha1').update(password).digest('hex');
	} else {
		return '';
	}
}
841700
def _hash(self, obj, parent, parents_ids=EMPTY_FROZENSET):
        """"""

        try:
            result = self[obj]
        except (TypeError, KeyError):
            pass
        else:
            return result

        result = not_hashed

        if self._skip_this(obj, parent):
            return

        elif obj is None:
            result = 'NONE'

        elif isinstance(obj, strings):
            result = prepare_string_for_hashing(
                obj, ignore_string_type_changes=self.ignore_string_type_changes,
                ignore_string_case=self.ignore_string_case)

        elif isinstance(obj, numbers):
            result = self._prep_number(obj)

        elif isinstance(obj, MutableMapping):
            result = self._prep_dict(obj=obj, parent=parent, parents_ids=parents_ids)

        elif isinstance(obj, tuple):
            result = self._prep_tuple(obj=obj, parent=parent, parents_ids=parents_ids)

        elif isinstance(obj, Iterable):
            result = self._prep_iterable(obj=obj, parent=parent, parents_ids=parents_ids)

        else:
            result = self._prep_obj(obj=obj, parent=parent, parents_ids=parents_ids)

        if result is not_hashed:  # pragma: no cover
            self[UNPROCESSED].append(obj)

        elif result is unprocessed:
            pass

        elif self.apply_hash:
            if isinstance(obj, strings):
                result_cleaned = result
            else:
                result_cleaned = prepare_string_for_hashing(
                    result, ignore_string_type_changes=self.ignore_string_type_changes,
                    ignore_string_case=self.ignore_string_case)
            result = self.hasher(result_cleaned)

        # It is important to keep the hash of all objects.
        # The hashes will be later used for comparing the objects.
        try:
            self[obj] = result
        except TypeError:
            obj_id = get_id(obj)
            self[obj_id] = result

        return result
580278
def hash(value, chars=None):
	''
	value = hash_func(value).hexdigest()
	if chars: value = value[:chars]
	return mark_safe(value)
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
1033376
public static byte[] stringToHash(String s) {
        if (s.length() % 2 != 0) {
            throw new IllegalArgumentException("Invalid hash string: " + s);
        }
        byte[] hash = new byte[s.length() / 2];
        for (int i = 0; i < s.length(); i += 2) {
            byte b = (byte) ((hexDigitValue(s.charAt(i)) << 4) + hexDigitValue(s.charAt(i + 1)));
            hash[i / 2] = b;
        }
        return hash;
    }
367281
private static int hash(String k1, String k2) {
    int h = (k1.hashCode() * 33) + k2.hashCode();
    return h ^ (h >>> 16);
  }