30 bool StoreSecret(
const wxString& aService,
const wxString& aKey,
const wxString& aSecret )
32 wxString display = aService + wxS(
":" ) + aKey;
34 CREDENTIALW cred = { 0 };
35 cred.Type = CRED_TYPE_GENERIC;
36 cred.TargetName = (LPWSTR) display.wc_str();
37 cred.CredentialBlobSize = (DWORD) aSecret.size();
38 cred.CredentialBlob = (LPBYTE) aSecret.utf8_str().data();
39 cred.Persist = CRED_PERSIST_ENTERPRISE;
41 return CredWriteW( &cred, 0 );
44 bool GetSecret(
const wxString& aService,
const wxString& aKey, wxString& aSecret )
46 wxString display = aService + wxS(
":" ) + aKey;
48 CREDENTIALW* cred =
nullptr;
49 bool result = CredReadW( display.wc_str(), CRED_TYPE_GENERIC, 0, &cred );
53 aSecret = wxString::FromUTF8( (
const char*) cred->CredentialBlob,
54 cred->CredentialBlobSize );