Add small wxSecretString helper for wiping strings values

This is simpler and more robust than remembering to call WipeString()
manually.
This commit is contained in:
Vadim Zeitlin
2021-01-10 01:21:45 +01:00
parent f8aa5785ce
commit fe197d7527
2 changed files with 64 additions and 0 deletions

View File

@@ -230,4 +230,30 @@ private:
#endif // wxUSE_SECRETSTORE/!wxUSE_SECRETSTORE
// Helper class ensuring WipeString() is called.
//
// It should only be used as a local variable and never polymorphically.
class wxSecretString : public wxString
{
public:
wxSecretString()
{
}
wxSecretString(const wxString& value)
: wxString(value)
{
}
explicit wxSecretString(const wxSecretValue& value)
: wxString(value.GetAsString())
{
}
~wxSecretString()
{
wxSecretValue::WipeString(*this);
}
};
#endif // _WX_SECRETSTORE_H_