Add conversions between wxSecretValue and wxString

This is less secure, but more convenient, than using raw pointers and in most
cases the password will already be stored in a wxString anyhow.
This commit is contained in:
Vadim Zeitlin
2016-06-04 19:19:15 +02:00
parent 1de80a72d9
commit 4154fbb8a3
4 changed files with 89 additions and 16 deletions

View File

@@ -104,6 +104,19 @@ const void *wxSecretValue::GetData() const
return m_impl ? m_impl->GetData() : NULL;
}
wxString wxSecretValue::GetAsString(const wxMBConv& conv) const
{
if ( !m_impl )
return wxString();
return wxString
(
static_cast<const char*>(m_impl->GetData()),
conv,
m_impl->GetSize()
);
}
#ifndef __WINDOWS__
/* static */
@@ -117,6 +130,13 @@ void wxSecretValue::Wipe(size_t size, void *data)
#endif // __WINDOWS__
/* static */
void wxSecretValue::WipeString(wxString& str)
{
for ( wxString::iterator it = str.begin(); it != str.end(); ++it )
*it = '*';
}
// ============================================================================
// wxSecretStore implementation
// ============================================================================