djb2

djb2 is a popular hash function. See e.g. here: http://www.cse.yorku.ca/~oz/hash.html

Implementation is obvious but I ripped the code from Github user drslumps djb2.tcl Gist . where you can also find another digit optimized implementation.

proc djb2 {{input ""} {result 5381}} {
    foreach c [split $input ""] {
        set result [expr {($result << 5) + $result + [scan $c %c] & 0xFFFFFFFF}]
    }        
    return $result
}