by rcconf · 10y ago · 0 comments
It's a bit tricky to fail someone in an interview because they don't know security. I think the better way to handle security in a company is to hire a programmer that knows it and teaches it to other programmers during code reviews.
http://security.stackexchange.com/questions/211/how-to-secur...
https://paragonie.com/blog/2016/02/how-safely-store-password...
In PHP:
$storeMe = password_hash($plaintext, PASSWORD_DEFAULT);
if (password_verify($plaintext, $storeMe)) {
// Logged in
}
The detail is totally abstracted away. All sane password hashing libraries offer this API.See: https://paragonie.com/blog/2016/02/how-safely-store-password...
EDIT - CANNOT REPLY:
> One major failure of this article:
>
> You should generate a random salt for each user and store it alongside the user
> record in the DB.
No, you shouldn't. Your library should do that for you, and store it as a single string that's opaque to the developer. > I completely disagree. This implies that my DB ORM handles password stuff,
> which doesn't make sense.
See the passlib section: https://paragonie.com/blog/2016/02/how-safely-store-password...You should generate a random salt for each user and store it alongside the user record in the DB.
I completely disagree. This implies that my DB ORM handles password stuff, which doesn't make sense.
Python 3 example:
Syntax: hashlib.pbkdf2_hmac(hash_name, password, salt, iterations, dklen=None)
Example:
>>> dk = hashlib.pbkdf2_hmac('sha256', b'password', b'salt', 100000)
>>> binascii.hexlify(dk)
b'0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5'
Extremely simple and safe to use. Trivial to store and save/retrieve the salt from DB.
How about:
You should use the md5 function to produce a string you can compare with the md5 function.
md5 is obsolete, does not offer much security, and should not be used in new programs except for the purposes of interoperating with old programs, and even in that case, one should weigh the risks of interoperation with the costs of replacing.
If you are looking for a suitable replacement for md5, you should instead be looking for specific use-cases, such as content verification (links...), authenticated content verification (links...), password verification (links...), random number generation (links...), shared secret encryption (links...)