DEV Community

Discussion on: Chat Application using PHP

 
jorgecasas profile image
Jorge Casas

No, seriously. Never use MD5 to encrypt a password. The are other methods more secure available php.net/manual/en/function.passwor...

Thread Thread
 
rupeshmohanty profile image
Rupesh Chandra Mohanty

Okay I will look into it. Thank you for the suggestion 😇

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇

You can use sha256 joining the string with an application token or salt, or a cookie hash and it will be ok. If you want more security you can use 512-bit encrypt such whirlpool, sha-512 and so

Thread Thread
 
rupeshmohanty profile image
Rupesh Chandra Mohanty

I was going to use uniqid() in php and join it with the password string. I will try your approach too. Thank you for the suggestion 😇

Thread Thread
 
reegodev profile image
Matteo Rigon

Please do not create your own auth implementation, you will regret it eventually ( there's a big yellow box in uniqid manual that says you should never use it to salt passwords).
Use one of the many well-known, tested and audited auth libraries.
If you really wanna learn how to implement a custom authentication I suggest you to browse the source code of said libraries and see how they handle it.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇

There's nothing bad on implementing own auth if you're a senior dev and you know all about what it implies. Specially when working on a big company and being in need to create a self implemented auth to avoid extra costs of Auth APIs (Oauth, Oauth2, SSO ...), you just need to pass a security audit and the tests after building it and before linking your services to it on production