3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Spoke $key = 'This is the key'; $secret = "TRUSTNO1"; $request = array( 'license' => $key, 'authentication' => hash_hmac('sha256', $key, $secret), ); ?> <?php // Hub $key_index = array( 'This is the key' => 'TRUSTNO1' ); if ($auth = $request['authentication']) { if ($key = $request['license'] && $secret = $key_index[$key]) { $new_hash = hash_hmac('sha256', $key, $secret); if (hash_compare($new_hash, $auth)) { var_dump('Authenticated.'); } else { var_dump('Not authenticated'); } } }

preferences:
53.29 ms | 402 KiB | 5 Q