tags:

views:

163

answers:

8

Im implementing users account in my website.I need to encrypt passwords from new members,however im getting crazy with many options that ive found to accomplish that.

Symmetric and asymmetric cryptosystems, public versus private keys, digital signatures, hash algorithms, RSA, DES, Rijndael, PGP, MD5, SHA-1, https, secure sockets, Camellia, IDEA; what does it all mean?

I dont even know the difference between MD5 and rinjdael,can somenone tell me the best option to encrypt?

A: 

Use TripleDES its supposed to be quite good, one of the best.

Buckley
3DES is a very weak algorithm, newer algorithms are a lot more safer.
Matias Valdenegro
I must be misinformed - which newer algorithms are better?
Buckley
AES, which replaces DES as a crypto standard.
Matias Valdenegro
Ok, but they should be hashing, not encrypting.
Steven Sudit
+9  A: 

If you are using asp.net, you can use the built in user account features.

If you insist on building your own, you shouldn't encrypt, you should hash and ONLY store the hash, not the actual password.

Here is a link to get you started.

comment update
membership providers for MySql
membership providers for Oracle

BioBuckyBall
ive already seen that,a long time ago.This time i dont want to use ASP.NET account features,cause i going to use MYSQL,and ORACLE
I added links for membership providers to the dbms's you mentioned.
BioBuckyBall
man i really appreciate your help,but i wont use ASP.NET features anyway.Thks for your help
@ozsenegal: You're doing it wrong. You should use off-the-shelf, proven code, not do it yourself. If you insist on doing it yourself, please publicize the fact that your site uses unproven security, written by developers who don't know one hash from another. You owe at least that much to your users. Or just take Lucas's advice and don't re-invent the wheel.
Craig Stuntz
+3  A: 

http://stackoverflow.com/questions/212510/c-what-is-the-easiest-way-to-encrypt-a-password-when-i-save-it-to-the-registry

you dont encrypt passwords you hash them, see the link for a similar issue

Pharabus
+1  A: 

If you want to store passwords in a database for example, I would recommend you to use HMAC (Hash-based Message Authentication Code); you'll need a cryptographic hash function (e.g. SHA-512) in combination with a secret key to generate the MAC. Also, it's important to note here that you don't encrypt the password, but you rather hash it.

For the encryption of locally saved passwords for example (though Bruce Schneier says you should write your passwords down on paper), you can use an asymmetric-key cryptosystem like RSA. In this case you'll have a key pair consisting of a public key, which you'll share with your friends, and a private key, which you should, well, keep private. The nice thing about RSA is that you can either encrypt messages with your public key and then decrypt them with your private key; or you can use it to digitally sign documents by using your private key to calculate the hash of a document, and then validate it using your public key. Pretty nifty!

Giu
If you use HMAC, what would you use for the key? Salt? If so, why not just salt the password and hash it yourself?
Steven Sudit
@Steven I'd use a randomly generated salt as the key. HMAC may be an overkill in this situation (`H(key1, H(key2 || message`), but it surely is stronger than a salted hash (`H(message || salt)`), i.e. HMAC is hardened against extension attacks for example.
Giu
Interesting. First, I'm used to seeing the salt come ahead of the message, which I believe would interfere with extension attacks. But I think that the main point of salting is to stop rainbow tables, not all possible attacks, so HMAC may indeed be a bit much. Then again, I don't see any great harm to using HMAC here, especially if it's iterated to strengthen it.
Steven Sudit
+1  A: 

You shouldn't encrypt the password but take a hash of it using a salt (to protect against rainbow tables) and SHA-256 or better. This means you don't have to keep a secret key and worry about loads of key management stuff and also means that no one (including yourself) can find out a users password from the data in your database (they can only confirm that they have guessed the right password).

It is also suggested that you use a lot (1000+) of iterations of the hash to make it slow to calculate (not too slow for the user entering the correct password but far too slow if you're hashing loads of words to see if any match the contents of your db).

If you google salts, rainbow tables, hashes etc there is loads of information out there.

Patrick
A: 

Here is a really good article that I used when I was first learning how to store passwords. This is a really good primer and it is written in C#

Scott Chamberlain
A: 

I think you could use MD5, it's simple to implement on .Net and it's a 128 bits (one way) cryptographic hash function. It has hash colission problems on wide ranges though.

Or you could check at Gost which is a 256 bits cryptographic hash function.

GOST Hash function

Mario
MD5 is broken, so no.
Steven Sudit
A: 

This has been answered before, but the short version is that you salt the password, hash it with at least SHA-256, and preferably use strengthening. If this doesn't make sense to you, you're not ready to write anything yet; keep researching.

Steven Sudit
This would be a fine opportunity to explain the otherwise inexplicable downvoting.
Steven Sudit