diff options
| author | Appleman1234 <applemansigloo@gmail.com> | 2016-12-15 18:25:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-15 18:25:42 +0900 |
| commit | cae526e65a20f3da2d8884c4d8e8978c54120000 (patch) | |
| tree | 2954153dd49f616f5018490058ff4bfbd17300d3 /inc/polyfill.php | |
| parent | b58fab98147a92c8e6d22f15d23684508b6bb811 (diff) | |
| parent | 5feae402cb55d49963bfd2c6f5a33d10690ecbc1 (diff) | |
Merge pull request #79 from lainchan/clean_prod_vichan_update
Merge vichan changes from upstream and changes directly applied to the site.
Diffstat (limited to 'inc/polyfill.php')
| -rw-r--r-- | inc/polyfill.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/inc/polyfill.php b/inc/polyfill.php new file mode 100644 index 00000000..ac40a00a --- /dev/null +++ b/inc/polyfill.php @@ -0,0 +1,28 @@ +<?php + +// PHP 5.4 + +if (!function_exists('hex2bin')) { + function hex2bin($data) { + return pack("H*" , $hex_string); + } +} + +// PHP 5.6 + +if (!function_exists('hash_equals')) { + function hash_equals($ours, $theirs) { + $ours = (string)$ours; + $theirs = (string)$theirs; + + $tlen = strlen($theirs); + $olen = strlen($ours); + + $answer = 0; + for ($i = 0; $i < $tlen; $i++) { + $answer |= ord($ours[$olen > $i ? $i : 0]) ^ ord($theirs[$i]); + } + + return $answer === 0 && $olen === $tlen; + } +} |
