Skip to content

Instantly share code, notes, and snippets.

View Metevier's full-sized avatar

Tyler Metevier Metevier

  • UIC
  • Louisville, KY
View GitHub Profile
@Metevier
Metevier / client-sessions.php
Created May 16, 2016 21:30
Implementation of Mozilla's node-client-sessions in PHP
<?php
if(!function_exists('hash_equals')) {
function hash_equals($str1, $str2) {
if(strlen($str1) != strlen($str2)) {
return false;
} else {
$res = $str1 ^ $str2;
$ret = 0;
for($i = strlen($res) - 1; $i >= 0; $i--) $ret |= ord($res[$i]);
return !$ret;