Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encrypt user passwords for forum registrations?

What is the most secure way to encrypt user passwords for phpBB or MyBB forum registrations? I don't want anyone to be able to access the user passwords, not even those who administrate the MySQL database, and also if someone manages to hack the database to not be able to view them. I want only the users who register to know their passwords.

like image 628
user1800997 Avatar asked Jan 20 '26 16:01

user1800997


2 Answers

I completely agree with the response Federico Razzoli, except for one thing. Indeed, hashing must be performed upstream, in any case not at the database level (so your question is probably off topic).

However simply using a hash function is not sufficient in terms of security. You remain vulnerable to dictionary attacks, rainbow table attacks, and some attacks by frequency analysis. It is essential to at least use a cryptographic salt.

However, the best is to use a key derivation function designed to store passwords. I suggest you to look at PBKDF2 (hash_pbkdf2 with PHP), bcrypt (password_hash with PHP, which by default uses a judicious algorithm, bcrypt currently) or scrypt.

Finally, your question suggests that you use phpBB, this forum engine should normally deal alone with the secure storage of passwords.

like image 102
mlpo Avatar answered Jan 23 '26 07:01

mlpo


You can use SHA512.

I see that you used the "mysql" tag. Please, don't use the SHA2() SQL function, or any other SQL hash function. If you do so, the plain strings will be sent across the net, and probably written in some logs.

Use the PHP hash() function instead, and specify 'sha256' as first parameter.

like image 40
Federico Razzoli Avatar answered Jan 23 '26 08:01

Federico Razzoli