3v4l.org

run code in 300+ PHP versions simultaneously
<?php function deriveSP800108HmacSHA256Key($length, $array, $string, $array2) { $n = $n2 = 1; $allocate = ''; // length = $length while ($n < $length) { $mac = hash_init('sha256', HASH_HMAC, $array); $allocate2 = pack("L", $n2); hash_update($mac, $allocate2); hash_update($mac, $string); hash_update($mac, pack("L", 0)); hash_update($mac, $array2); $allocate2 = pack("L", $n * 8); hash_update($mac, $allocate2); $final = hash_final($mac, true); $allocate .= $final; $n2++; } return unpack('C*', $allocate); } var_dump(deriveSP800108HmacSHA256Key(32, 'array', 'foo', 'array2'));

preferences:
59.84 ms | 402 KiB | 5 Q