When writing a WPF application, the PasswordBox
stores the entered password as a SecureString
. This totally makes sense. However, I want to send the password via a HTTP API, and the HttpClient
PostAsync seems to accept strings for form-encoded data.
I am aware that other people have asked related questions, most notably Is SecureString ever practical in a C# application?, but I have not found a satisfactory method to send this SecureString
to the Http endpoint, without first converting it to a String
. The conversion totally defeats the object of SecureString
in the first place (because it puts the plaintext right back into the managed memory).
Is there a canonically correct (and preferably straightforward) way to do this?
For complete disclosure - I have no control over the HTTP API.