1

What's secret parameter in the hash_hmac function and how to add a secret key ?

for example :

$mac = hash_hmac('sha256', $cookie, SECRET_KEY);

from https://stackoverflow.com/a/17266448/3578287

Community
  • 1
  • 1
AliN11
  • 2,387
  • 1
  • 25
  • 40

1 Answers1

0

The string. This is so called salt. It will be combined with data you want to hash and makes cracking your hash more complicated (but not impossible).

$mac = hash_hmac('sha256', $cookie, 'sdKJ7_dghsJ5dj');
Nafscript
  • 5,155
  • 2
  • 17
  • 15
  • thanks.So it can be every string ? it should be a complicated or simple string ? what if i put a easy string ? – AliN11 Sep 27 '14 at 08:54
  • It can be any string. [Using HMAC in PHP](http://abhinavsingh.com/blog/2009/12/how-to-add-content-verification-using-hmac-in-php/) – Nafscript Sep 27 '14 at 09:12