public void LoremIpsumHashMatches() { // ReSharper disable StringLiteralTypo const string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor" + " incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud " + "exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute " + "irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla " + "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia " + "deserunt mollit anim id est laborum."; const string expectedHash = "8BA760CAC29CB2B2CE66858EAD169174057AA1298CCD581514E6DB6DEE3285280EE6E3A54C" + "9319071DC8165FF061D77783100D449C937FF1FB4CD1BB516A69B9"; var calculatedHash = _cryptoUtils.ComputeSha512Hash(text); Assert.AreEqual(expectedHash, calculatedHash); }
public string GetApiSignature(string methodName, Dictionary <string, string> parameters, string apiSecret) { var rand = _randomUtils.GetRandomAlphanumericString(6); var orderedParams = parameters.OrderBy(pair => pair.Key); var queryString = orderedParams.BuildQueryString(); var plainText = $"{rand}/{methodName}?{queryString}#{apiSecret}"; var hash = _cryptoUtils.ComputeSha512Hash(plainText).ToLower(); return($"{rand}{hash}"); }