this algorithm was created for sdbm a publicdomain reimplementation of ndbm database library it was found to do well in scrambling bits causing better distribution of the keys and fewer splits it also happens to be a good general hashing function with good distribution the actual function pseudo code is for i in i lenstr hashi hashi 1 65599 stri what is included below is the faster version used in gawk there is even a faster duffdevice version the magic constant 65599 was picked out of thin air while experimenting with different constants it turns out to be a prime this is one of the algorithms used in berkeley db see sleepycat and elsewhere source http www cse yorku caozhash html function implements sdbm hash easy to use great for bits scrambling iterates over each character in the given string and applies function to each of them sdbm algorithms 1462174910723540325254304520539387479031000036 sdbm scramble bits 730247649148944819640658295400555317318720608290373040936089 function implements sdbm hash easy to use great for bits scrambling iterates over each character in the given string and applies function to each of them sdbm algorithms 1462174910723540325254304520539387479031000036 sdbm scramble bits 730247649148944819640658295400555317318720608290373040936089
def sdbm(plain_text: str) -> int:
    
    hash_value = 0
    for plain_chr in plain_text:
        hash_value = (
            ord(plain_chr) + (hash_value << 6) + (hash_value << 16) - hash_value
        )
    return hash_value