Ejemplo n.º 1
0
int main(int argc, char **argv) {
	
	if (argc < 6 || argc > 6) {
		std::cout << "Usage: ./prog --encrypt --files_dir= --keys_dir=" << std::endl
			      << "or ./prog --decrypt --file_dir= --key-dir=" << std::endl;
		return 0;
	}

	Cipher cipher;

	if (!strcmp(argv[1], "--encrypt")) {

		path filesDir(argv[3]);
		path keysDir(argv[5]);

		cipher.groupUp(filesDir);
		cipher.encrypt(filesDir, keysDir);
	}

	else if (!strcmp(argv[1], "--decrypt")) {

		path fileDir(argv[3]);
		path keyDir(argv[5]);

		cipher.decrypt(fileDir, keyDir);
	}
	 
	else {
		std::cout << "Usage: ./prog --encrypt --files_dir= --keys_dir=" << std::endl
			<< "or ./prog --decrypt --file_dir= --key-dir=" << std::endl;
	}


	return 0;
}
Ejemplo n.º 2
0
QByteArray IrcParser::decrypt(Network *network, const QString &bufferName, const QByteArray &message, bool isTopic)
{
#ifdef HAVE_QCA2
    if (message.isEmpty())
        return message;

    if (!Cipher::neededFeaturesAvailable())
        return message;

    Cipher *cipher = qobject_cast<CoreNetwork *>(network)->cipher(bufferName);
    if (!cipher || cipher->key().isEmpty())
        return message;

    return isTopic ? cipher->decryptTopic(message) : cipher->decrypt(message);
#else
    Q_UNUSED(network);
    Q_UNUSED(bufferName);
    Q_UNUSED(isTopic);
    return message;
#endif
}