コード例 #1
0
ファイル: note.cpp プロジェクト: guija/QOwnNotes
/**
 * Returns decrypted note text if it is encrypted
 * The crypto key has to be set in the object
 */
QString Note::getDecryptedNoteText() {
    QString noteText = this->noteText;
    QString encryptedNoteText = getEncryptedNoteText();

    if (encryptedNoteText == "") {
        return noteText;
    }

    // decrypt the note text
    BotanWrapper botanWrapper;
    botanWrapper.setPassword(cryptoPassword);
    botanWrapper.setSalt(BOTAN_SALT);
    QString decryptedNoteText = botanWrapper.Decrypt(encryptedNoteText);

    // fallback to SimpleCrypt
    if (decryptedNoteText == "") {
        SimpleCrypt *crypto = new SimpleCrypt(static_cast<quint64>(cryptoKey));
        decryptedNoteText = crypto->decryptToString(encryptedNoteText);
    }

    if (decryptedNoteText == "") {
        return noteText;
    }

    // get regular expression for the encrypted string
    QRegularExpression re = getEncryptedNoteTextRegularExpression();

    // replace the encrypted text with the decrypted text
    noteText.replace(re, decryptedNoteText);
    return noteText;
}
コード例 #2
0
ファイル: note.cpp プロジェクト: LiangWei88/QOwnNotes
/**
 * Checks if note text can be decrypted
 */
bool Note::canDecryptNoteText() {
    QString encryptedNoteText = getEncryptedNoteText();

    if (encryptedNoteText == "") {
        return false;
    }

    // decrypt the note text
    SimpleCrypt* crypto = new SimpleCrypt(static_cast<quint64>(cryptoKey));
    QString decryptedNoteText = crypto->decryptToString(encryptedNoteText);

    return decryptedNoteText != "";
}
コード例 #3
0
ファイル: note.cpp プロジェクト: guija/QOwnNotes
/**
 * Checks if note text can be decrypted
 */
bool Note::canDecryptNoteText() {
    QString encryptedNoteText = getEncryptedNoteText();

    if (encryptedNoteText == "") {
        return false;
    }

    // decrypt the note text
    BotanWrapper botanWrapper;
    botanWrapper.setPassword(cryptoPassword);
    botanWrapper.setSalt(BOTAN_SALT);
    QString decryptedNoteText = botanWrapper.Decrypt(encryptedNoteText);

    // fallback to SimpleCrypt
    if (decryptedNoteText == "") {
        SimpleCrypt *crypto = new SimpleCrypt(static_cast<quint64>(cryptoKey));
        decryptedNoteText = crypto->decryptToString(encryptedNoteText);
    }

    return decryptedNoteText != "";
}
コード例 #4
0
inline bool ClientFactory::AuthUser(astring &strUser, astring &strPasswd)
{
    /* Admin is a Super User */
    if (strUser == "admin")
    {
        VidClientConf  cData;
        m_Conf.GetClientConf(cData);
        SimpleCrypt crypt;
        astring strDummy = cData.stradminpasswd().c_str();
        QString strDePasswd = cData.stradminpasswd().c_str();
        if (crypt.decryptToString(strDePasswd).toStdString() == strPasswd)
        {
            return true;
        } else
        {
            return false;
        }
    }

    return false;
}
コード例 #5
0
ファイル: note.cpp プロジェクト: LiangWei88/QOwnNotes
/**
 * Returns decrypted note text if it is encrypted
 * The crypto key has to be set in the object
 */
QString Note::getDecryptedNoteText() {
    QString noteText = this->noteText;
    QString encryptedNoteText = getEncryptedNoteText();

    if (encryptedNoteText == "") {
        return noteText;
    }

    // decrypt the note text
    SimpleCrypt* crypto = new SimpleCrypt(static_cast<quint64>(cryptoKey));
    QString decryptedNoteText = crypto->decryptToString(encryptedNoteText);

    if (decryptedNoteText == "") {
        return noteText;
    }

    // get regular expression for the encrypted string
    QRegularExpression re = getEncryptedNoteTextRegularExpression();

    // replace the encrypted text with the decrypted text
    noteText.replace(re, decryptedNoteText);
    return noteText;
}
コード例 #6
0
ファイル: settings.cpp プロジェクト: Drifter321/admintool
void Settings::ReadSettings()
{
    if(!pSettings->value("windowMaximized", pMain->isMaximized()).toBool())
    {
        pMain->restoreGeometry(pSettings->value("windowSize", pMain->saveGeometry()).toByteArray());
    }

    pMain->restoreState(pSettings->value("windowState", pMain->saveState()).toByteArray());

    pMain->GetUi()->splitter->restoreState(pSettings->value("splitterState", pMain->GetUi()->splitter->saveState()).toByteArray());

    pMain->GetUi()->rulesSplitter->restoreState(pSettings->value("rulesSplitterState", pMain->GetUi()->rulesSplitter->saveState()).toByteArray());

    pMain->GetUi()->browserSplitter->restoreState(pSettings->value("browserSplitterState", pMain->GetUi()->browserSplitter->saveState()).toByteArray());

    pMain->GetUi()->browserTable->horizontalHeader()->restoreState(pSettings->value("browserTableState", pMain->GetUi()->browserTable->horizontalHeader()->saveState()).toByteArray());

    pMain->GetUi()->playerTable->horizontalHeader()->restoreState(pSettings->value("playerTableState", pMain->GetUi()->playerTable->horizontalHeader()->saveState()).toByteArray());

    pMain->GetUi()->rulesTable->horizontalHeader()->restoreState(pSettings->value("rulesTableState", pMain->GetUi()->rulesTable->horizontalHeader()->saveState()).toByteArray());

    bool darkTheme = pSettings->value("darkTheme", false).toBool();

    pMain->showLoggingInfo = pSettings->value("showLoggingInfo", true).toBool();

    uint temp = pSettings->value("logPort", pMain->u16logPort).toUInt();

    if(temp <= PORT_MAX && temp >= PORT_MIN)
    {
        pMain->u16logPort = temp;
    }

    if(darkTheme)
    {
        pMain->GetUi()->menuSettings->actions().at(0)->setChecked(true);
        pMain->darkThemeTriggered();
    }

    pSettings->beginGroup("servers");
    QStringList keys = pSettings->childKeys();

    for(int i = 1; i <= keys.size(); i++)
    {   
        QStringList list = pSettings->value(QString::number(i), QStringList()).toStringList();

        if(list.size() == 0 || list.size() > 2)
        {
            continue;
        }

        if(pMain->CheckServerList(list.at(0)) == AddServerError_None)
        {
            ServerInfo *info = new ServerInfo(list.at(0));
            serverList.append(info);

            int row = pMain->GetUi()->browserTable->rowCount();
            pMain->GetUi()->browserTable->insertRow(row);

            QTableWidgetItem *item = new QTableWidgetItem();
            QTableWidgetItem *id = new QTableWidgetItem();
            id->setData(Qt::DisplayRole, serverList.size());

            item->setTextColor(queryingColor);
            item->setText(QString("Querying server %1...").arg(info->ipPort));
            item->setToolTip(info->ipPort);
            pMain->GetUi()->browserTable->setItem(row, 0, id);
            pMain->GetUi()->browserTable->setItem(row, 4, item);

            InfoQuery *infoQuery = new InfoQuery(pMain);
            infoQuery->query(&info->host, info->port, id);

            if(list.size() == 2)
            {
                SimpleCrypt encrypt;
                encrypt.setKey(list.at(0).toLongLong());
                QString pass = encrypt.decryptToString(list.at(1));
                if(encrypt.lastError() == SimpleCrypt::ErrorNoError)
                {
                    info->rconPassword = pass;
                    info->saveRcon = true;
                }
            }
        }
    }
    pSettings->endGroup();
    this->SaveSettings();//Call this again to make sure we cleaned up any garbage entries
}