Generate an md5 hash of a given string.
335463
def md5_digest(instr):
    '''
    
    '''
    return salt.utils.stringutils.to_unicode(
        hashlib.md5(salt.utils.stringutils.to_bytes(instr)).hexdigest()
    )
234559
public static String toMD5hash(final String s) {

        String hash = null;
        if (null != s) {
            try {
                final MessageDigest digest = MessageDigest.getInstance("MD5");
                digest.update(s.getBytes(Charset.forName("utf-8")));
                final byte[] md5sum = digest.digest();
                final BigInteger bigInt = new BigInteger(1, md5sum);
                hash = bigInt.toString(16);
            } catch (final NoSuchAlgorithmException e) {
                throw new RuntimeException("MD5 digest algorithm implementation not found", e);
            }
        }
        return hash;
    }
1099307
def md5_object(obj):
    
    hasher = hashlib.md5()
    if isinstance(obj, basestring) and PY3:
        # in python3 convert strings to bytes before hashing
        hasher.update(obj.encode('utf-8'))
    else:
        hasher.update(obj)

    md5 = hasher.hexdigest()
    return md5
398353
def make_hash(s, n_bytes):
    """"""
    raw_h = int(md5(s.encode('utf-8')).hexdigest()[:n_bytes], 16)
    # Make it a signed int.
    return 16**n_bytes//2 - raw_h
772087
def MD5Hash(password):
    
    md5_password = md5.new(password)
    password_md5 = md5_password.hexdigest()
    return password_md5
444231
static String md5(String origin) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(origin.getBytes("UTF-8"));
      BigInteger bi = new BigInteger(1, md.digest());
      StringBuilder hash = new StringBuilder(bi.toString(16));

      while (hash.length() < 32) {
        hash.insert(0, "0");
      }

      return hash.toString();
    } catch (Exception e) {
      return getUuid();
    }
  }
625818
def from_string(cls, hash, **context):
        """"""
        salt, checksum = parse_mc2(hash, cls.ident, handler=cls)

        return cls(salt=salt, checksum=checksum)
700487
def _get_file_md5(filename):
    """"""
    md5_data = md5()
    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(128*md5_data.block_size), b''):
            md5_data.update(chunk)
    return md5_data.hexdigest()
33789
public static String MD5EncodeToNum(String str) {
		String reStr = null;
		try {
			reStr = new String(str);
			MessageDigest md = MessageDigest.getInstance("MD5");
			reStr = byteArrayToNumString(md.digest(reStr.getBytes()));
		} catch (Exception e) {
		}
		return reStr;
	}
23767
def _string_hash(s):
    """"""
    h = 5381
    for c in s:
        h = h * 33 + ord(c)
    return h
184809
function(data, algorithm) {
    if (arguments.length === 1) {
      algorithm = 'md5';
    }
    return crypto.createHash(algorithm).update(data).digest('hex');
  }
1253007
def file_md5(self, file_name):
        """"""
        with open(file_name, "rb") as f:
            file_contents = f.read()
            file_hash = hashlib.md5(file_contents).hexdigest()
        return file_hash
708167
public static byte[] md5Bytes(String str) {
        if (str == null) return null;
        MessageDigest md5;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException(ex);
        }
        return md5.digest(str.getBytes());
    }
1340072
public static MD5Digest fromString(String md5String) {
    byte[] bytes;
    try {
      bytes = Hex.decodeHex(md5String.toCharArray());
      return new MD5Digest(md5String, bytes);
    } catch (DecoderException e) {
      throw new IllegalArgumentException("Unable to convert md5string", e);
    }
  }
735726
def textMD5(text):
    ''''''
    m = hash_md5()
    if isinstance(text, str):
        m.update(text.encode())
    else:
        m.update(text)
    return m.hexdigest()
1369560
def file_md5(f, size=8192):
    ""
    md5 = hashlib.md5()
    while True:
        data = f.read(size)
        if not data:
            break
        md5.update(data)
    return md5.hexdigest()
10982
public static String md5Hex(String s) {
    try {
      MessageDigest messageDigest = MessageDigest.getInstance("MD5");
      byte[] md5bytes = messageDigest.digest(s.getBytes("UTF-8"));
      return ByteString.of(md5bytes).hex();
    } catch (NoSuchAlgorithmException e) {
      throw new AssertionError(e);
    } catch (UnsupportedEncodingException e) {
      throw new AssertionError(e);
    }
  }