1

I'm trying to generate a cache key from a mongo bson query document. Is GetHashCode() good for this purpose? Is there a better way to generate an actual MD5 or SHA hash given a bson document?

Harindaka
  • 4,658
  • 8
  • 43
  • 62

1 Answers1

1

In this Microsoft Link they offer a good example of hashing a string with SHA256, the result is returned as a byte[], which can be turned into a string using This answer. Thus can be used in cache.

Zorrero
  • 181
  • 5
  • I'm looking for something that will produce the same hash despite the order of fields being different since this is a bson object. I could use the above to come up with a custom solution but I do not want to reinvent the wheel if its already done somewhere in the bson library code. – Harindaka Jun 23 '21 at 21:58