Skip to content

Instantly share code, notes, and snippets.

@MicheleBertoli
Created April 28, 2014 07:58
Show Gist options
  • Save MicheleBertoli/11364834 to your computer and use it in GitHub Desktop.
Save MicheleBertoli/11364834 to your computer and use it in GitHub Desktop.
Java vs PHP
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.binary.Base64;
String sStringToDigest = InputString + "&" + sSecretString;
byte[] bMac = DigestUtils.md5 (sStringToDigest.getBytes());
String sMacEncoded = Base64.encodeBase64String (bMac);
sMacEncoded = sMacEncoded.substring (0,24);
$string_to_digest = $input_string . '&' . $secret_string;
$mac = hash('md5', $string_to_digest, true);
$mac_encoded = base64_encode($mac);
$mac_encoded = substr($mac_encoded, 0, 24);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment