I have built my own lock screen for Windows 7. Thus, it uses a password to unlock itself. So I decided to store only the hash code of the password string (For example, I call the GetHashCode method of the string "Password123"). Now I have the task of storing the number. How would I do this in the most secure way? Or is using the hashcode of the password string even the best way of doing it? My goal is to keep someone from gaining access to this number and ultimately, keeping someone from discovering the password.
Here are some possible methods I have come up with so far:
- Store the Password's hash code in an unencrypted plain text file along side the main program.
- Store the Password's hash code in an encrypted text file along side the main program (This introduces the problem of storing and getting a suitable key for encryption)
- Store the Password's hash code in a small compiled C# library.
- Do as above, but encrypt the resulting assembly. Then, to load it, simply read all the bytes into memory, decrypt, then use Assembly.Load to load the raw byte array.
Now is there any better (more secure) ways of keeping someone from discovering the hash code that I am trying to store on the hard drive?
EDIT: As per the comments below, I am working on a patch to the program to use a hashing algorithm to get a hashcode of my password. Now the question is "How would I securely store an array of bytes on the hard drive? All the options above still apply.
Thanks for your help in advance.