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 not the same. What I noticed is that before the encoding to base 64, both functions have the same result. So, for me the problem is not on the generation of the key but on the encoding.
Anybody able to help please ?