How to hash a string

From Cuis CookBook
Revision as of 20:09, 12 May 2025 by Nmingott (talk | contribs) (syntax hilight)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Example 1.

Sometimes it is useful to make a number that represents string. This is usually called an hash, one of its properties is that if you change the string a tiny bit the hash number becomes quite different.

'Hello world' hash.     "=> 136137888 "


Example 2. MD5

WebUtils md5Digest: 'foobar'.     "=>"   '3858F62230AC3C915F300C664312C63F'

Exercise. Try to hash 'Hello World' and see how much different it is.

Exercise. Explore the Cryptography-DigitalSignatures package for another implementation of the hashing function.