MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setKey

Method setKey

app/src/AI/KeyVault.cpp:99–115  ·  view source on GitHub ↗

* @brief Encrypts and writes the given plaintext key to QSettings. */

Source from the content-addressed store, hash-verified

97 * @brief Encrypts and writes the given plaintext key to QSettings.
98 */
99void AI::KeyVault::setKey(ProviderId provider, const QString& plaintext)
100{
101 auto trimmed = plaintext.trimmed();
102 ZeroOnDestroy scrub(trimmed);
103
104 if (trimmed.isEmpty()) {
105 clearKey(provider);
106 return;
107 }
108
109 const auto cipher = m_simpleCrypt.encryptToString(trimmed);
110 m_settings.beginGroup(QStringLiteral("ai/keys"));
111 m_settings.setValue(settingsKey(provider), cipher);
112 m_settings.endGroup();
113
114 qCDebug(serialStudioAI) << "Key set for" << settingsKey(provider);
115}
116
117/**
118 * @brief Removes the stored key for the given provider.

Callers 2

KeyVaultMethod · 0.45
CredentialVaultMethod · 0.45

Calls 2

isEmptyMethod · 0.80
encryptToStringMethod · 0.80

Tested by

no test coverage detected