Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [safety] string encrypt input. #2061

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void MountAskPasswordDialog::handleConnect()

loginObj.insert(kUser, usernameLineEdit->text());
loginObj.insert(kDomain, domainLineEdit->text());
loginObj.insert(kPasswd, passwordLineEdit->text());
loginObj.insert(kPasswd, encryptPasswd(passwordLineEdit->text()));

if (passwordCheckBox->isChecked()) {
loginObj.insert(kPasswdSaveMode, kSavePermanently);
Expand All @@ -173,6 +173,14 @@ void MountAskPasswordDialog::handleConnect()
accept();
}

QString MountAskPasswordDialog::encryptPasswd(const QString &passwd)
{
//todo use encrypt-plugin
QByteArray byteArray = passwd.toUtf8();
QByteArray encodedByteArray = byteArray.toBase64();
return QString::fromUtf8(encodedByteArray);
}

void MountAskPasswordDialog::handleButtonClicked(int index, QString text)
{
Q_UNUSED(text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class MountAskPasswordDialog : public DTK_WIDGET_NAMESPACE::DDialog
void setDomain(const QString &domain);
void setUser(const QString &user);

QString encryptPasswd(const QString &passwd);

enum {
kNeverSave,
kSaveBeforeLogout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ QString CifsMountHelper::mountRoot()

QString CifsMountHelper::decryptPasswd(const QString &passwd)
{
// TODO(xust): encrypt and decrypt passwd
return passwd;
QByteArray encodedByteArray = passwd.toUtf8();
QByteArray decodedByteArray = QByteArray::fromBase64(encodedByteArray);
return QString::fromUtf8(decodedByteArray);
}

uint CifsMountHelper::invokerUid()
Expand Down
Loading