tags:

views:

66

answers:

3

I have a class that stores a users user data (user ID & password) from the login window in my application. Currently I'm using SecureString to store the password, but in certain places I need the original password to verify things. (it has to be plain text at that moment)

Does anyone know a secure way to store it in memory where it can easily be re converted to plain text if it is needed?

+1  A: 

It looks like SecureString itself isn't secure and there are tools to get the secure string. You can write your own code, to encrypt the string, break into parts and store it, but again no security is complete, if you need to use the password like say for Database login, etc. hacker can find out and break your code. Security is not one point, so lot of things like code obfuscation, etc. goes hand into hand. Tools like SmartAssembly can protect strings by auto encrypting, it. The other idea would be to store the hash, instead of the password itself, and the hash is basically created using some random parameter, so that it can't be recreated, one time passwords.

Priyank Bolia
you have a good point, but the salt added to the hash, where does one store that? Or does it not matter if that's in plain sight??
Tony
salt is random like the date? etc. Once you are authenticated to the server, create some cookie like mechanism and store the credentials on the server, like IP address, username, password with auto expire feature.
Priyank Bolia
A: 

you can encrypt password by MD5 and for compare you can encrypt inputed data and copmare two string

ali moharrami
A: 

Consider CryptProtectData():

http://www.pinvoke.net/default.aspx/crypt32.cryptprotectdata

It can use either the current user key or the local machine key. In a Web setting (i. e. ASP.NET), you want to use local machine. As long as you have a single Web server where encryption/decryption takes place.

Seva Alekseyev