def djb2_hash(text, size):
    """ Implementation of the djb2 hash, a simple hash function with a
    configurable table size.

    ** Do NOT use for cryptography! **

    """
    hash = 5381
    for char in text:
        hash = (hash << 5) + hash + ord(char)
    return hash % size
