Obviously, when you store a password, you should use something similar to bcrypt before you store it in in the database.
But I have a client who wants to add the ability to add a “secret code” to each database entry that a user will have to enter before gaining access to that entry.
The “secret key” isn’t exactly as critical as a password, so should I bcrypt this secret code, or does it even need it?
4
It looks like your client wants to use those “secret codes” as a fine-grained authorization scheme: Only people who are authorized to access those entries should know the corresponding secret code.
If that is the case, then those secret codes serve a similar purpose to passwords and should be subject to the same security standards.
It depends. What is the benefit of not using encryption?
- Under some circumstances, it can be cheaper to implement and debug.
- Easier for admins and others to figure out a password / secret access code.
What are the drawbacks of not using encryption?
- Potential legal liability, depending on the context.
- Easier for admins and others to figure out a password / secret access code.
Unless this is for an environment where the security must be weak and multiple users must have access to each others passwords (these environments do exist), I think using encryption is clearly the better option.