private bool ValidateInstallResponse(OAuthState installState) { var queryStringBuilder = new QueryStringBuilder { StartsWith = null }; queryStringBuilder.Add(AppResources.CodeKeyword, installState.AuthorizationCode); queryStringBuilder.Add(AppResources.ShopKeyword, installState.ShopName); queryStringBuilder.Add(AppResources.TimestampKeyword, installState.AuthorizationTimestamp); var secretKeyBytes = Encoding.UTF8.GetBytes(this.Configuration.SecretKey); var installResponseBytes = Encoding.UTF8.GetBytes(queryStringBuilder.ToString()); using (var hmacsha256 = new HMACSHA256(secretKeyBytes)) { var generatedInstallResponseHmacHashBytes = hmacsha256.ComputeHash(installResponseBytes); var generatedInstallResponseHmacHash = ByteArrayToHexString(generatedInstallResponseHmacHashBytes); return(generatedInstallResponseHmacHash.Equals(installState.HmacHash)); } }
private bool ValidateInstallResponse(OAuthState installState) { var queryStringBuilder = new QueryStringBuilder { StartsWith = null }; queryStringBuilder.Add(AppResources.CodeKeyword, installState.AuthorizationCode); queryStringBuilder.Add(AppResources.ShopKeyword, installState.ShopName); queryStringBuilder.Add(AppResources.TimestampKeyword, installState.AuthorizationTimestamp); var secretKeyBytes = Encoding.UTF8.GetBytes(this.Configuration.SecretKey); var installResponseBytes = Encoding.UTF8.GetBytes(queryStringBuilder.ToString()); using (var hmacsha256 = new HMACSHA256(secretKeyBytes)) { var generatedInstallResponseHmacHashBytes = hmacsha256.ComputeHash(installResponseBytes); var generatedInstallResponseHmacHash = ByteArrayToHexString(generatedInstallResponseHmacHashBytes); return generatedInstallResponseHmacHash.Equals(installState.HmacHash); } }