mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-27 07:17:59 +01:00
35 lines
1,018 B
PHP
35 lines
1,018 B
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Contracts\Hashing\Hasher;
|
||
|
|
||
|
class IpsHasher implements Hasher
|
||
|
{
|
||
|
public function make($value, array $options = array())
|
||
|
{
|
||
|
return md5(md5($options['salt']) . md5(static::ips_sanitize($value)));
|
||
|
}
|
||
|
|
||
|
public function check($value, $hashedValue, array $options = array())
|
||
|
{
|
||
|
return static::make($value, ['salt' => $options['salt']]) === $hashedValue;
|
||
|
}
|
||
|
|
||
|
public function needsRehash($hashedValue, array $options = array())
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
static public function ips_sanitize($value)
|
||
|
{
|
||
|
$value = str_replace('&', '&', $value);
|
||
|
$value = str_replace('\\', '\', $value);
|
||
|
$value = str_replace('!', '!', $value);
|
||
|
$value = str_replace('$', '$', $value);
|
||
|
$value = str_replace('"', '"', $value);
|
||
|
$value = str_replace('<', '<', $value);
|
||
|
$value = str_replace('>', '>', $value);
|
||
|
$value = str_replace('\'', ''', $value);
|
||
|
|
||
|
return $value;
|
||
|
}
|
||
|
}
|