I wrote last week about an evening I spent throwing together a password manager for Windows and Windows Mobile. As I wrote at the time, one of the motivations was to try writing some encryption code.
I’ve finally got around to writing it, and wanted to post it here with a few comments.
This is what I needed code to be able to do:
- Encrypt and decrypt data based on a user-provided password
- Encrypt/decrypt consistently on both Windows desktops and Windows Mobile devices – a file encrypted on a Windows Mobile PDA should be able to be decrypted on a Windows desktop, and vice versa
The System.Security.Cryptography library in .NET makes this fairly straightforward – the class I have written to add crypto support to the password manager app needed only a few hundred lines of code in total.
I’ve shared a simplified version of the source at the end of this post.