Assuming we have an md5 hash:
With ruby:
>Digest::MD5.hexdigest("ZZtop")
=> "d3e5c7c22df12b70e882f593432a3bdd"
Possible field types:
:type => String
:type => Hash
Which should I choose?
In MongoDB, hash does not mean a cryptographic fingerprint (as in MD5 or SHA-1). It means hash as in hash table (a data structure that allows the storage of key-value pairs).
You have to use a string to store a MD5 fingerprint.
String, or better yet is to use Binary, its about half the size.
> Digest::MD5.hexdigest("ZZtop").size
=> 32
> Digest::MD5.digest("ZZtop").size
=> 16
You may have to get around the UTF8 check by explicitly telling stating its BSON::Binary.
> BSON::Binary.new(Digest::MD5.digest("ZZtop"))