Skip to content

Commit

Permalink
Corrected c# example to show that you need to skip the hash key
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Maenzanise committed Feb 14, 2025
1 parent 12c5f21 commit dce9d61
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/generating_hash.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ private function CreateHash($values, $IntegrationKey) {
private static string GenerateTwoWayHash(Dictionary<string, string> items, Guid guid)
{
string concat = string.Join("",
items.Select(c => (c.Value != null ? c.Value.Trim() : "")).ToArray()
items
.Where(c => !string.Equals(c.Key, "HASH", StringComparison.OrdinalIgnoreCase))
.Select(c => c.Value?.Trim() ?? "")
);

SHA512 check = SHA512.Create();

byte[] resultArr = check.ComputeHash(Encoding.UTF8.GetBytes(concat + guid));
return ByteArrayToString (resultArr);
return ByteArrayToString(resultArr);
}

public static string ByteArrayToString(byte[] ba)
Expand Down

0 comments on commit dce9d61

Please sign in to comment.