The version of vichan running on lainchan.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
490B

  1. <?php
  2. // PHP 5.4
  3. if (!function_exists('hex2bin')) {
  4. function hex2bin($data) {
  5. return pack("H*" , $hex_string);
  6. }
  7. }
  8. // PHP 5.6
  9. if (!function_exists('hash_equals')) {
  10. function hash_equals($ours, $theirs) {
  11. $ours = (string)$ours;
  12. $theirs = (string)$theirs;
  13. $tlen = strlen($theirs);
  14. $olen = strlen($ours);
  15. $answer = 0;
  16. for ($i = 0; $i < $tlen; $i++) {
  17. $answer |= ord($ours[$olen > $i ? $i : 0]) ^ ord($theirs[$i]);
  18. }
  19. return $answer === 0 && $olen === $tlen;
  20. }
  21. }