CodeExplorer xor example
return hash_equals($this->storage->
getToken($namespacedId),
$this->
derandomize($token->
getValue()));
} private function getNamespace(): string
{ return \
is_callable($ns =
$this->namespace
) ?
$ns() :
$ns;
} private function randomize(string
$value): string
{ $key =
random_bytes(32
);
$value =
$this->
xor($value,
$key);
return sprintf('%s.%s.%s',
substr(hash('xxh128',
$key), 0, 1 +
(\
ord($key[0
]) % 32
)),
rtrim(strtr(base64_encode($key), '+/', '-_'
), '='
),
rtrim(strtr(base64_encode($value), '+/', '-_'
), '='
));
} private function derandomize(string
$value): string
{ $parts =
explode('.',
$value);
if (3 !== \
count($parts)) { return $value;
} $key =
base64_decode(strtr($parts[1
], '-_', '+/'
));