34class Token implements Stringable {
55 $this->secret = $secret;
70 $suffixLen = strlen( self::SUFFIX );
71 $len = strlen( $token );
72 if ( $len <= 32 + $suffixLen ||
73 substr( $token, -$suffixLen ) !== self::SUFFIX ||
74 strspn( $token,
'0123456789abcdef' ) + $suffixLen !== $len
79 return hexdec( substr( $token, 32, -$suffixLen ) );
88 return hash_hmac(
'md5', $timestamp . $this->salt, $this->secret,
false ) .
89 dechex( $timestamp ) .
111 public function match( $userToken, $maxAge =
null ) {
116 if ( $timestamp ===
null ) {
119 if ( $maxAge !==
null && $timestamp < (
int)
wfTimestamp( TS_UNIX ) - $maxAge ) {
125 return hash_equals( $sessionToken, $userToken );
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.