protected function weakHash($key): string
    {
        if (is_null($this->cryptokey)) {
            $key = $this->salt . $key;
            $key = hash('ripemd160', $key);
            // 16^16 should be enough of the hash to avoid collisions
            return substr($key, 17, 16);
        }
        $key = $key . $this->salt;
        $hash = sodium_crypto_generichash($key, $this->cryptokey, 16);
        $hexhash = sodium_bin2hex($hash);
        return substr($hexhash, 6, 20);
    }