Reputation: 4768
I want to store a System.SecureString in the registry. Is that possible? And how would I go about doing it?
Would my program be able to decrypt the string again when running the next time?
Upvotes: 1
Views: 1396
Reputation: 3192
Take a look at the Storing Private Data article in MSDN. You'll have to pInvoke the LsaStorePrivateData() call.
Upvotes: 1
Reputation: 755041
It's not possible to do in encrypted form without a helper layer. It' doesn't natively support any form of serialization and in fact cannot even be inspected in it's native form. To even get any information out of it you need to go through PInvoke or the SecureStringToBSTR
API. Both of which will give you access to the string
in unencrypted form.
One way I could see this working is
SecureString
to a BSTR
via SecureStringToBSTR
BSTR
Of course you'd need to use an encryption mechanism which was re-usable between instances of your program.
Upvotes: 3