Skip to content

Commit

Permalink
feat: [safety] string encrypt input.
Browse files Browse the repository at this point in the history
1.encrypt dbus pwd input

Log: as title
Bug: https://pms.uniontech.com/bug-view-259823.html
  • Loading branch information
pppanghu77 authored and deepin-bot[bot] committed Jun 28, 2024
1 parent 782a19a commit 74329ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
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

0 comments on commit 74329ae

Please sign in to comment.