c# - Setting the text of a PasswordBox -


i creating application requires user login (username + password). secure application, i'm using wpf's passwordbox.securepassword securely create hash of password (using sha512cryptoserviceprovider, hashing custom stream) use password rfc2898derivebytes. let's have aes-256-cbc implementation securely retrieves , stores key+iv not issue.
implementing way users able store password don't have put them every time log in. far able store password securely using aes custom implementation , can read password securely (that is, without ever putting in memory in plain text).
having problem when try replace text in passwordbox. passwordbox.securepassword read-only , have tried use passwordbox.securepassword.appendchar(somechar) field/value remains empty. imagine passwordbox.securepassword returns copy (securestring.copy()) , not original variable (looking @ .net source code confirms this).
there way can achieve want or need create custom wpf control?

to set text of passwordbox in wpf use following code:

passwordbox1.password = "yourpassword"; 

you don't need use securepassword function long able password in plain text able set using password function. mentioned securepassword function read because retrieves password in secure form, not allow set text in passwordbox. msdn documentation

if want able put secure password in passwordbox can use method, cannot put in plain text, because you'd asking break encryption, if have key , can decrypt first , set text in passwordbox.

to view password entered in passwordbox in plain text use following code:

passwordbox1.password; 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -