0

There are lots of questions about password_hash() function but non answered my question:

I am trying to find information about password_hash function return value. All I see is that it returns the actual hash.

I am planning to save the hash in SQL table.

Can the hash contain quotes? If it can contain quotes, will I have to escape the hash before inserting it?

Thank you

1 Answer 1

3

There is no need for escaping a BCrypt hash, regarding SQL-injection. A BCrypt hash calculated by password_hash() is base64 encoded, it contains only "harmless" characters of this alphabet...

./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

...plus the & sign to separate the parameters. That said, it is still a good idea to use parametrized queries of course.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, parametrized queries are the way to go indeed. Good to know that password_hash() is base64.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.