1

How can I use Bcrypt in my .php files?

This is how I would set this up and correct me if I am wrong

I have looked over the info at the following link. How do you use bcrypt for hashing passwords in PHP?

If I understand this correctly I would take the function list and place that into a .php file. Then on my main program I would use something like: $isGood = $bcrypt->verify('password', $hash); Which my encrypted password is now a variable of $isGood.

$isGood is what I want to store into the database? correct?

How do I set up my database?

What is my field type? Do I just leave it blank? or label it as text? How do I set up the DataBase to store this type of passwor? I know I wouldn't use md5 or sha1 as the field type, because that will just encrypted it even more, or do I?

Community
  • 1
  • 1
Slap Shot
  • 75
  • 1
  • 2
  • 7

1 Answers1

0

According to the example provided $isGood would be either true or false, not the password. As for your database, you should use binary(60) for the field type

Basically what you're trying to accomplish is storing the password encrypted in the database. Since the same string will always hash to the same value(be careful of newlines) you can then check the hash of the user input against what is in you database. This is what the verify() method is doing in your example. Then if verify return true you can proceed, otherwise the password is wrong.

I just recently set something like this up PM is you have anymore questions.

EDIT

After reading this again I think I should remind you to always follow these guidelines when asking a question Specifically please post actual examples of code in the future as this will help make your question more relevant to other people. Aloha.

Community
  • 1
  • 1
noel
  • 2,257
  • 3
  • 24
  • 39
  • Thank you so much for getting back to me, I was looking at the variable the wrong way. I have a few errors that is generating, but I will struggle though this and see if I cant fix the errors. – Slap Shot Oct 10 '12 at 02:22
  • Anytime. That's what we're all here for. – noel Oct 10 '12 at 02:25