Java-Code
public static String encryptMD5_Salt(String content) { String resultString = ""; String appkey = "acdf,kef"; byte[] a = appkey.getBytes(); byte[] datSource = content.getBytes(); byte[] b = new byte[a.length + 4 + datSource.length]; int i; for (i = 0; i < datSource.length; i++) { b[i] = datSource[i]; } b[i++] = (byte) 143; b[i++] = (byte) 112; b[i++] = (byte) 131; b[i++] = (byte) 143; for (int k = 0; k < a.length; k++) { b[i] = a[k]; i++; } try { MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(b); resultString = new HexBinaryAdapter().marshal(md5.digest()); } catch (Exception e) { e.printStackTrace(); } return resultString.toLowerCase(); }
PHP-Code:
function javaMd5($data) { assert(is_array($data)); $dataString = byteArrayToString($data); $hashString = md5($dataString); return $hashString; } function byteArrayToString($b) { assert(is_array($b)); $asciiString = ''; for ($i = 0; $i < count($b); $i++) { $asciiString .= chr($b[$i]); } return $asciiString; } $re=array_merge (unpack("c*", pack("a*", $content)), pack("c", pack("l", 143)), unpack("c", pack("l", 112)), unpack("c", pack("l", 131)), unpack("c", pack("l", 143)), unpack("c*", pack("a*", "acdf,kef")) ); $re = javaMd5($re);