Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Hashing functions in Daml?Forum ↗

Hashing functions in Daml?

App Development5 posts437 views11 likesLast activity Feb 2021
LU
LucianoOP
Feb 2021

Do we have any built-in typeclasses or functions for calculating hashes from within Daml?

Something analogous to the built-in hash function every java object has?

(don’t ask why :wink: )

CO
cocreature
Feb 2021

We don’t provide something generic for hashing values. What we do provide is DA.Text.sha256 which hashes a Text value. If you combine that with show, you can hash other values but of course you are relying on the Show instance doing something sensible. If it just omits certain parts of your values (e.g., because you have a function in your record), the hash will be garbage. It probably will also be fairly slow.

In general, I would be very cautious with doing this type of stuff in DAML itself and try to push it to the client-side instead.

BE
bernhard
Feb 2021

why??

AN
anthony
Feb 2021

I think we’re witnessing the creation of a very elusive bug some time in the future

← Back to Discussions