1 2 3 4 5 6 7
local h c h=5381 for c in ${(s::)1}; do h=$(( ( (h << 5) + h + #c ) % 0xffffffff )) done printf ${2:-%d} $h # vim: ft=zsh et sts=4 ts=4 sw=4