public SecureCompare ( string left, string right ) : bool | ||
left | string | |
right | string | |
Результат | bool |
private bool PayloadMatches(string signature, string payload) { var sha1Hasher = new Sha1Hasher(); string computedSignature = sha1Hasher.HmacHash(service.PrivateKey, payload).ToLower(); var crypto = new Crypto(); return crypto.SecureCompare (computedSignature, signature); }
private void ValidateSignature(string signature, string payload) { string matchingSignature = null; string[] signaturePairs = signature.Split('&'); foreach (string signaturePair in signaturePairs) { if (signaturePair.IndexOf('|') >= 0) { String[] candidatePair = signaturePair.Split('|'); if (Service.PublicKey.Equals(candidatePair[0])) { matchingSignature = candidatePair[1]; break; } } } Crypto crypto = new Crypto(); string computedSignature = crypto.HmacHash(Service.PrivateKey, payload).ToLower(); if (!crypto.SecureCompare(computedSignature, matchingSignature)) { throw new InvalidSignatureException(); } }
private bool PayloadMatches(string signature, string payload) { var sha1Hasher = new Sha1Hasher(); string computedSignature = sha1Hasher.HmacHash(service.PrivateKey, payload).ToLower(); var crypto = new Crypto(); return(crypto.SecureCompare(computedSignature, signature)); }