Hashes given byte string

        @param data - string to hash
        @param length - if not specifed, entire string is hashed,
                otherwise only first length bytes
760335
def update(self, data, length=None):
        
        if self.digest_finalized:
            raise DigestError("No updates allowed")
        if not isinstance(data, bintype):
            raise TypeError("A byte string is expected")
        if length is None:
            length = len(data)
        elif length > len(data):
            raise ValueError("Specified length is greater than length of data")
        result = libcrypto.EVP_DigestUpdate(self.ctx, c_char_p(data), length)
        if result != 1:
            raise DigestError("Unable to update digest")
1076419
final byte[] hash(final byte[] input, final int offset, final int len) {
		mdHash.update(input, offset, len);
		return mdHash.digest();
	}
38036
function hashString(string) {
  // This is the hash from JVM
  // The hash code for a string is computed as
  // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  // where s[i] is the ith character of the string and n is the length of
  // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  // (exclusive) by dropping high bits.
  let hashed = 0;
  for (let ii = 0; ii < string.length; ii++) {
    hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  }
  return smi(hashed);
}
416321
public final void write(byte[] data) {
    if (sendBinary) {
      int prev = 0;
      for (int i = 0;i < data.length;i++) {
        if (data[i] == -1) {
          rawWrite(data, prev, i - prev);
          send(new byte[]{-1, -1});
          prev = i + 1;
        }
      }
      rawWrite(data, prev, data.length - prev);
    } else {
      for (int i = 0;i < data.length;i++) {
        data[i] = (byte)(data[i] & 0x7F);
      }
      send(data);
    }
  }
1145577
public static int hash32(final String text, int from, int length) {
        return hash32(text.substring( from, from+length));
    }
943306
def get_hash(self, length=HASH_LENGTH):
        

        data_hash = ""
        if not self.data_str:
            return data_hash

        encoded_data_str = self.data_str
        if sys.version_info.major == 2:
            # In Py2, only unicode needs to be encoded.
            if isinstance(self.data_str, unicode):
                encoded_data_str = self.data_str.encode('utf-8')
        else:
            # data_str should always be unicode on python 3
            encoded_data_str = self.data_str.encode('utf-8')

        data_hash = hashlib.sha1(encoded_data_str).hexdigest()

        return data_hash[:length]
643170
public static byte[] md5Hash(String data, Charset charset) throws NoSuchAlgorithmException {
		return md5Hash(data.getBytes(charset));
	}
958569
public static byte[] sha224Hash(String data, Charset charset) throws NoSuchAlgorithmException {
		return sha224Hash(data.getBytes(charset));
	}
489924
public static final Bytes of(byte[] data, int offset, int length) {
    Objects.requireNonNull(data);
    if (length == 0) {
      return EMPTY;
    }
    byte[] copy = new byte[length];
    System.arraycopy(data, offset, copy, 0, length);
    return new Bytes(copy);
  }
887313
public long hash64( final byte[] data, int length, int seed) {
		final long m = 0xc6a4a7935bd1e995L;
		final int r = 47;

		long h = (seed&0xffffffffl)^(length*m);

		int length8 = length/8;

		for (int i=0; i<length8; i++) {
			final int i8 = i*8;
			long k =  ((long)data[i8+0]&0xff)      +(((long)data[i8+1]&0xff)<<8)
					+(((long)data[i8+2]&0xff)<<16) +(((long)data[i8+3]&0xff)<<24)
					+(((long)data[i8+4]&0xff)<<32) +(((long)data[i8+5]&0xff)<<40)
					+(((long)data[i8+6]&0xff)<<48) +(((long)data[i8+7]&0xff)<<56);

			k *= m;
			k ^= k >>> r;
					k *= m;

					h ^= k;
					h *= m; 
		}

		switch (length%8) {
		case 7: h ^= (long)(data[(length&~7)+6]&0xff) << 48;
		case 6: h ^= (long)(data[(length&~7)+5]&0xff) << 40;
		case 5: h ^= (long)(data[(length&~7)+4]&0xff) << 32;
		case 4: h ^= (long)(data[(length&~7)+3]&0xff) << 24;
		case 3: h ^= (long)(data[(length&~7)+2]&0xff) << 16;
		case 2: h ^= (long)(data[(length&~7)+1]&0xff) << 8;
		case 1: h ^= (long)(data[length&~7]&0xff);
		h *= m;
		};

		h ^= h >>> r;
		h *= m;
		h ^= h >>> r;

		return h;
	}
1074083
public static String calculateHash(MessageDigest d, byte[] bytes)
    {
        if (bytes == null)
        {
            return null;
        }

        d.update(bytes);
        return ByteUtilities.encode(d.digest());
    }
1191802
public static int hash32(final byte[] data, int length, int seed) {
        // 'm' and 'r' are mixing constants generated offline.
        // They're not really 'magic', they just happen to work well.
        final int m = 0x5bd1e995;
        final int r = 24;

        // Initialize the hash to a random value
        int h = seed^length;
        int length4 = length/4;

        for (int i=0; i<length4; i++) {
            final int i4 = i*4;
            int k = (data[i4+0]&0xff) +((data[i4+1]&0xff)<<8)
                    +((data[i4+2]&0xff)<<16) +((data[i4+3]&0xff)<<24);
            k *= m;
            k ^= k >>> r;
            k *= m;
            h *= m;
            h ^= k;
        }
        
        // Handle the last few bytes of the input array
        switch (length%4) {
        case 3: h ^= (data[(length&~3) +2]&0xff) << 16;
        case 2: h ^= (data[(length&~3) +1]&0xff) << 8;
        case 1: h ^= (data[length&~3]&0xff);
                h *= m;
        }

        h ^= h >>> 13;
        h *= m;
        h ^= h >>> 15;

        return h;
    }
435507
def hash_str(data, hasher=None):
    """"""
    hasher = hasher or hashlib.sha1()
    hasher.update(data)
    return hasher
828183
public static byte[] checkLength(byte[] data, int size) {
        if (data == null) {
            throw new IllegalArgumentException("Data to check the length of are null.");
        }
        if (data.length < size) {
            throw new IllegalArgumentException("Invalid length: " + data.length);
        }
        return data;
    }
1044772
@Override
    public final long hash(byte[] buffer) {
        long hash = hash(buffer, 1);
        return (hash == HashFunction.NON_HASH_CODE) ? HashFunction.MAX_HASH_CODE : hash;
    }
852322
public static MD5Hash digest(byte[] data, int start, int len) {
    byte[] digest;
    MessageDigest digester = DIGESTER_FACTORY.get();
    digester.update(data, start, len);
    digest = digester.digest();
    return new MD5Hash(digest);
  }
1021317
@Override
    public void write(String b) throws IOException {
        long code = 0;
        for (int i = 0; i < b.length(); i++) {
            code = 31 * code + b.charAt(i);
        }
        hashCode += hash(code);
    }