예제 #1
0
/**
 * Decrypts the actual text using the password
 * @param password Password
 * @return Decrypted text
 */
QByteArray MainWindow::decrypt(QString password)
{
    AES crypto;

    QString hashedPassword = QString( QCryptographicHash::hash(( password.toUtf8() ),QCryptographicHash::Md5).toHex() );

    QByteArray key = crypto.hexStringToByte(hashedPassword);
    QByteArray data = QByteArray::fromBase64( ui->textEdit_mainWindow_surface->toPlainText().toUtf8() );

    QByteArray decrypted = crypto.decrypt(data, key);

    return decrypted;
}
예제 #2
0
/**
 * Encrypts the actual text using the password
 * @param password Password
 * @return Encrypted text
 */
QByteArray MainWindow::encrypt(QString password)
{
    AES crypto;

    QString hashedPassword = QString( QCryptographicHash::hash(( password.toUtf8() ),QCryptographicHash::Md5).toHex() );

    QByteArray key = crypto.hexStringToByte(hashedPassword);
    QByteArray data = ui->textEdit_mainWindow_surface->toHtml().toUtf8();

    QByteArray encrypted = crypto.encrypt(data, key);

    return encrypted;
}