Skip to content

Instantly share code, notes, and snippets.

@ormaaj
Last active May 9, 2022 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ormaaj/11529334 to your computer and use it in GitHub Desktop.
Save ormaaj/11529334 to your computer and use it in GitHub Desktop.
Generate a composite key from a list of fields
public static string GetKeyFromRecord<T>(IEnumerable<string> pRecordProps) where T : HashAlgorithm, new() {
using (T hashAlg = new T()) {
IEnumerable<byte> result = pRecordProps
.Select(x => hashAlg.ComputeHash(Encoding.UTF8.GetBytes(x ?? string.Empty)))
.SelectMany(y => y);
return Convert.ToBase64String(hashAlg.ComputeHash(result.ToArray()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment