How to force PHP to create HMAC-SHA1 strings like Objective-C?

I am trying to implement an authentication solution with PHP and Objective-C. Both languages ​​create their own HMAC-SHA1 encoded strings with the same key and the same secret.

Apparently, they seem to differ in their way of how they do it.

On the Objective-C side, I use OAuthCustomer as a signature class that creates a correctly looking encoded string:

/3n/d4sKN6k3I7nBm1qau59UukU=

On the PHP side, I use the built-in function hash_hmac ('sha1', ...) with base64 encoding, which produces this:

ZmY3OWZmNzc4YjBhMzdhOTM3MjNiOWMxOWI1YTlhYmI5ZjU0YmE0NQ==

Then I tried to use another function (mentioned here ), and this leads to base64 encoding:

NWY1ODUwOWE3NGI4NWU5ZTIxMDYzMTNmNzk3NTYxMDQ4OWE1MmUzNQ==

I have no idea how I can fix this problem, and I don’t even know why this is happening.

,

+5
1

, . ( Stackoverflow .)

- PHP , . ( ). , , :

 hash_hmac("sha1", $data, $key, $raw_output=TRUE);

 md5($str, $raw_output=TRUE);

 hash("sha1", $data, $raw_output=TRUE);
+20

All Articles