secret_provider = $secret_provider; } /** * Hash an identifier with a purpose namespace. * * @param string $purpose Purpose namespace. * @param string $identifier Raw identifier. */ public function hash_identifier( string $purpose, string $identifier ): string { $purpose = strtolower( preg_replace( '/[^a-z0-9_:-]/', '', $purpose ) ?? 'generic' ); return hash_hmac( 'sha256', $purpose . '|' . trim( $identifier ), $this->secret_provider->get_secret() ); } }