SecurePasswordTextBox - A textbox that uses the SecureString class

Posted by: Glavs Blog, on 26 Feb 2006 | View original | Bookmarked: 0 time(s)

In a previous post, I mentioned that I was working on a small side project to develop a version of a standard Winforms textbox control that utilises the SecureString class from the System.Security namespace in .Net V2. Well I have finally released this 'SecurePasswordTextBox' control for others to use and comment upon. It comes with full source code so you can see what I have done. Note that I have not done anything particularly elegant in the way it handles textual input, however its small, and works for the very brief testing I performed.

Note that this is something I have been tinkering with as I continuing to write the last chapter I have due for the upcoming 'Beginning AJAX with ASP.NET' book, hence why not too much testing has gone into it. I kind of poke around in this little pet project for a while when my head gets too full of book writing and needs a quick break.

I really wanted this for my own (yet another) personal project of moving my password manager application which I wrote way back in .Net V1.1 days (oh how I remember.....). In its new incarnation as a .net V2 app, I wanted to utilise the SecureString class to hold the password instances, but its not that easy getting text into it via a windows forms app, without using a standard form of input. None of which supports the SecureString. So, I wrote this little control.

You can download it here ( ).

I'd love to hear any feedback, or even if you just find it useful. If you happen to do any bug fixes, or have any suggestions I'd be particularly interested in those.

It doesn't come with any documentation. you simply drag it into a form and use it like a textbox. It does NOT display any textual entry, but rather uses whatever is defined in the 'PasswordChar' property field to display when you have typed a character. Ifno character is defined, then it defaults to an asterisk.

You can access the contents of whatever is input via 2 new properties.

'SecureText' - is an instance of the SecureString class with whatever data has been entered into it.
'CharacterData' - is a byte array that will return the characters held within the SecureStrig instance as a byte array. Not as safe as using the SecureString instance, but more for convenience.

The source code comes with a very minimalistic demo app to show you how to use it.

P.S. Add the control to your control toolbox to mkae things easier at design time.

Category: ASP.NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 7064 | Hits: 233

Similar Posts

  • New Entity Framework Feature CTP for VS2010 Beta 2 more
  • Entirely unobtrusive and imperative templates with Microsoft Ajax Library Preview 6 more
  • Behaviors vs Subclassing in Silverlight more
  • Building a class browser with Microsoft Ajax 4.0 Preview 5 more
  • Kobe - Oh Dear Lord Why?! more
  • Outside my element: A CSS Trick more
  • Updates to the TextBox Word / Character Counter Control more
  • Display data hierarchy in the RadGridView more
  • Client Templating with jQuery more
  • NavigationWindow, WinFormsHost and TextBoxes: backspace bug more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD