public function generate($table, $key, $length = 12, $lowercase = false)
    {
        $foundHash = false;
        $db = Application::make(Connection::class);
        while ($foundHash == false) {
            $string = $this->getString($length);
            if ($lowercase) {
                $string = strtolower($string);
            }
            $cnt = $db->GetOne("select count(" . $key . ") as total from " . $table . " where " . $key . " = ?",
                array($string));
            if ($cnt < 1) {
                $foundHash = true;
            }
        }

        return $string;
    }