/// <summary> /// Verified this ApiKey with provided hashed ApiKey. /// </summary> public bool Verify(string hashedApiKey) { if (string.IsNullOrWhiteSpace(hashedApiKey) || hashedApiKey.Length != IdAndPasswordHashedLength) { return(false); } string hashedApiKeyIdPart = hashedApiKey.Substring(0, IdPartLength); string hashedApiKeyPasswordPart = hashedApiKey.Substring(IdPartLength); if (!string.Equals(IdPart, Normalize(hashedApiKeyIdPart))) { return(false); } return(V3Hasher.VerifyHash(hashedApiKeyPasswordPart, PasswordPart)); }
/// <summary> /// Verified this ApiKey with provided hashed ApiKey. /// </summary> public bool Verify(string hashedApiKey) { if (string.IsNullOrWhiteSpace(hashedApiKey) || hashedApiKey.Length != IdAndPasswordHashedLength) { return(false); } string hashedApiKeyIdPart = hashedApiKey.Substring(0, IdPartBase32Length); string hashedApiKeyPasswordPart = hashedApiKey.Substring(IdPartBase32Length); if (!string.Equals(IdPart, Normalize(hashedApiKeyIdPart))) { return(false); } // The verification is not case sensitive. This is to maintain the existing behavior that ApiKey authentication is not case-sensitive. return(V3Hasher.VerifyHash(hashedApiKeyPasswordPart.ToUpper().FromBase32String(), PasswordPart)); }