Base64_encode different between Java and PHP
Here is my problem : I have a JAVA function to generate an encrypted string. I have to do the same thing in PHP. My Java function : String generateSignature () { byte[] Sequence = ("hello").getBytes("UTF-8"); Mac HMAC = Mac.getInstance("HMACSHA256"); HMAC.init("SECRET_KEY"); byte[] Hash = HMAC.doFinal(Sequence); String Signature = new String(Base64.encodeBase64(Hash)); return Signature; } My PHP function : function generateSignature() { $sequence = "hello"; $encrypted = hash_hmac('sha256', $sequence, "SECRET_KEY"); return base64_encode($encrypted); } The return value of the two functions are