Calculate the MD5 of a given String

@param string
String to be MD5'ed
@return MD5'ed String
171489
public static String calculateMD5(String string) {
		byte[] hash;

		try {
			hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException("Huh, MD5 should be supported?", e);
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException("Huh, UTF-8 should be supported?", e);
		}

		StringBuilder hex = new StringBuilder(hash.length * 2);

		for (byte b : hash) {
			int i = (b & 0xFF);
			if (i < 0x10)
				hex.append('0');
			hex.append(Integer.toHexString(i));
		}

		return hex.toString();
	}
644995
@Override
    public String hexMD5(String value) {
        return String.valueOf(Hex.encodeHex(md5(value)));
    }
1082837
function MD5(source) { // @arg String - source string
                       // @ret MD5HashHexString
//{@dev
    $valid($type(source, "String"), MD5, "source");
//}@dev

    var md5 = DataType["Array"]["toHexStringArray"](
                    MD5_encode(
                        DataType["Uint8Array"]["fromString"](source) ) );

    return md5.join("");
}
702343
public static function toBytes ($string)
		{
			$value = null;
			$string = strtoupper($string);

			preg_match('/(\d+)\s?([KMGT]?)/', $string, $match);

			if (isset($match[ 2 ]))
			{
				$digit = (int) $match[ 1 ];
				switch ($match[ 2 ])
				{
					case 'K':
						$value = $digit << 10;
						break;

					case 'M':
						$value = $digit << 20;
						break;

					case 'G':
						$value = $digit << 30;
						break;

					case 'T':
						$value = $digit << 40;
						break;

					default:
						$value = $digit;
						break;
				}
			}

			return $value;
		}
451498
protected function getChecksum($string)
    {
        $length = strlen($string);
        $checksum = 0;

        for ($i = 0; $i < $length; ++$i) {
            $checksum += ord($string{$i}) * $i;
        }

        return $checksum;
    }
1081117
public function setString($string)
    {
        if (null === $string) {
            throw new Exception('The string cannot be null.');
        }

        $this->hash = md5($string);

        $this->convertHashToArrayOfBoolean();

        return $this;
    }
298184
def md5_string(s):
    
    m = hashlib.md5()
    m.update(s)
    return str(m.hexdigest())
1176596
static function randmd5($length = 8, $seed = null)
    {
        if (empty($seed)) {
            $seed = self::string(16);
        }
        return substr(md5($seed . rand(111111, 999999)), 0, $length);
    }
1008381
public static function str_to_hex($string) {
        $hex = '';

        for ($i = 0; $i < strlen($string); $i++) {
            $hex .= dechex(ord($string[$i]));
        }

        return $hex;
    }
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);
    }
  }
67019
public static function decode($string)
    {
        return ($string === self::NULL) ? null : strtr($string, self::$decodeMap);
    }
59272
public static function hashCode($string) {
		// Code from https://stackoverflow.com/a/40688976/3918483
		$hash = 0;
		if(!is_string($string)) {
			return $hash;
		}

		$len = mb_strlen($string, 'UTF-8');
		if($len === 0) {
			return $hash;
		}
		for($i = 0; $i < $len; $i++) {
			$c = mb_substr($string, $i, 1, 'UTF-8');
			$cc = unpack('V', iconv('UTF-8', 'UCS-4LE', $c))[1];
			$hash = (($hash << 5) - $hash) + $cc;
			$hash &= $hash; // 16bit > 32bit
		}
		return $hash;
	}
462911
public static function decode($string)
    {
        if (is_array($string)) {
            foreach ($string as $k => $substring) {
                $string[$k] = static::decode($substring);
            }
        } else {
            $string = urldecode($string);
        }

        return $string;
    }
369892
function md5 (str) {
    if (!str) str = '';
    const h = crypto.createHash('md5');
    return h.update(str).digest('hex');
}
763530
private function decrypt($string = "")
    {
        $key = $this->config->get('gateway.asanpardakht.key');
        $iv = $this->config->get('gateway.asanpardakht.iv');

        try {

            $soap = new SoapClient("https://services.asanpardakht.net/paygate/internalutils.asmx?WSDL");
            $params = array(
                'aesKey' => $key,
                'aesVector' => $iv,
                'toBeDecrypted' => $string
            );

            $response = $soap->DecryptInAES($params);
            return $response->DecryptInAESResult;

        } catch (\SoapFault $e) {
            return "";
        }
    }
877766
private function detectEncoding($string)
    {
        static $enclist = ['UTF-8', 'ASCII', 'ISO-8859-1', 'Windows-1252'];
        if (function_exists('mb_detect_encoding')) {
            return mb_detect_encoding($string, $enclist, true);
        }
        $result = false;
        foreach ($enclist as $item) {
            try {
                $sample = iconv($item, $item, $string);
                if (md5($sample) === md5($string)) {
                    $result = $item;
                    break;
                }
            } catch (ContextErrorException $e) {
                unset($e);
            }
        }

        return $result;
    }
909975
public static function decodeURLSafe($string)
    {
        $remainder = strlen($string) % 4;

        if ($remainder <> 0) {
            $paddingLength = 4 - $remainder;
            $string .= str_repeat('=', $paddingLength);
        }

        return base64_decode(str_replace(array('-', '_'), array('+', '/'), $string));
    }