How can I encrypt password data in a database usin

2020-02-02 12:54发布

I am connecting to a MySQL database with PHP and the CodeIgniter Framework. I want to store my passwords encrypted in the database and would like to know the best way to do this.

标签: php database
9条回答
Anthone
2楼-- · 2020-02-02 13:13

Never store passwords. Use a one way hash and store that.

查看更多
不美不萌又怎样
3楼-- · 2020-02-02 13:15

Use a hashing function; MD5 will do fine. Don't store the password, store the hash. Then, to log users in, hash the password they entered and compare it to the hash in the database; if the hashes match, they're legit.

Also, add a salt to the password before you hash it. This can be easy as just appending a string to the password, like your domain name or some other data that's unique to your app. This prevents hackers from using rainbow tables against your hashes.

查看更多
家丑人穷心不美
4楼-- · 2020-02-02 13:20

I agree with hashing and salting. I disagree with picking a site-wide hash. Use a different salt for each user to prevent dictionary attacks against all your passwords at once.

查看更多
登录 后发表回答