Java - repetitive hmacSHA1 hashing - how to convert to PHP? -


how convert following java php?

byte[] bytearray1 = key1.getbytes("utf8"); byte[] bytearray2 = key2.getbytes("utf8"); byte[] bytearray3 = key3.getbytes("utf8"); byte[] bytearray4 = key4.getbytes("utf8");  mac mac = mac.getinstance("hmacsha1"); secretkeyspec derivedkey = new secretkeyspec(bytearray1, "hmacsha1"); mac.init(derivedkey); derivedkey = new secretkeyspec(mac.dofinal(bytearray2), "hmacsha1"); } mac.init(derivedkey); derivedkey = new secretkeyspec(mac.dofinal(bytearray3), "hmacsha1"); mac.init(derivedkey); derivedkey = new secretkeyspec(mac.dofinal(bytearray4), "hmacsha1"); 

from research i've done, looks if we'd remove last 2 lines, neatly convert php follows:

hash_hmac("sha1", $key2, $key1, true); 

however, how convert type of reiterative hashing php?

note: i've tried following unsuccessfully:

$derivedkey = hash_hmac("sha1", $key2, $key1, true); $derivedkey = hash_hmac("sha1", $key3, $derivedkey, true); $derivedkey = hash_hmac("sha1", $key4, $derivedkey, true);   


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

ios - Possible to get UIButton sizeThatFits to work? -