Hashing for objects and lists #12
hasenj
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Today I was looking for a way to hash objects in Javascript in order to be able to use objects as keys to hashmaps
I found the cyrb53 hash on StackOverflow.
I liked the idea and tried to extend it to hash not just strings but anything.
I basically noticed the function is split into 3 parts: init, digest, sum
I wanted to extend the "digest" part to not only digest strings but also numbers, booleans, and ojects/arrays composed of such.
Here's my first iteration. I started using it and it seems to be working fine (for now anyway)
https://gist.github.com/hasenj/b2f294593f5de4c8c965b83f79eef73b
But in all honesty hashing is something I hardly know anything about. So I'd love some feedback.
Beta Was this translation helpful? Give feedback.
All reactions