Answer the question
In order to leave comments, you need to log in
SecureString, WinForms
It is given: WinForms, normal TextBox where the password is entered.
Question: How to correctly read data from this textbox into SecureString? Handle every keystroke from the keyboard in the testbox? Give an example, if not difficult.
Answer the question
In order to leave comments, you need to log in
SecureString makes it harder to get the key by dumping your process's memory. We are talking about those keys that are constantly used by the application, for example, to access a third-party API (usually passwords do not apply to them, since the password is not stored in its pure form). If you store the key in a string or byte[], then it is easy to get it by creating a memory dump of the process and opening it in a regular text editor.
So whatever you need. It is best to save key information in a file, first encrypted with a password. After entering the password, there is no need to keep it in memory, just decrypt the file with access keys (and store the keys in SecureString).
If you really need to keep the password in memory (for example, to access the DBMS), then here is the simplest option :
var secure = new SecureString();
foreach (char c in textbox1.Text)
{
secure.AppendChar(c);
}
Have you read this?
1. social.msdn.microsoft.com/Forums/vstudio/en-US/69e82b78-08c5-4b37-85db-d270b1005ad5/how-to-set-mode-password-for-textbox-control
2. stackoverflow.com/questions /2555984/quick-question-how-to-set-a-text-box-for-inputing-password-in-winforms
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question