I need to be able to query by this value, so Hash::check doesn't work since it returns a boolean... seems my only option is to use another (less secure than bcrypt) method of hashing?
It's in the nature of the algorithm itself. You can't search for a salted hash - that's the idea behind it. Different hashes will be generated with the same input. So the answer is: You have to use another hashing algorithm which always returns the same output. And last but not least is less secure.
Maybe you can tell us something about your intention. Why do you wanna do such an unusual query?
@bart I am storing sensitive personal information (government issued ID # in this case) and need administrators to have the ability to search by (and edit) such information. I've been storing an encrypted value, but when searching tons of records also storing a hash makes sense. Thanks for the explanation about bcrypt, I wasn't realizing it was like that always.
@bashy thank you for the link, looking at the Hashing class provides some nice insights as to the PHP behind it. I looked around the code for the Auth::attempt() method as well and it appears that the record is found given the other (non-password) credentials, and then the Hash::check() method is called separately... so it's still not part of the query. After learning the nature of bcrypt, that certainly makes sense. It's unfortunately looking like I'll need to salt+hash using another more insecure algorithm to achieve what I want in this case.
There is no way of defining the bcrypt salt somewhere ? It would still be secure because nobody should know which salt you are using but it would generate constant hashes.
@developeritsme this is a pretty old thread. I looked at using the encryption library, but that would not have been very efficient query-wise. You'd have to query all the rows and then filter (decrypt) them. What I ended up doing is storing both an encrypted version of the value, and a hashed version of the value + salt string that I put in config which is the same every time. Now I can allow efficient searches for this value (just a simple WHERE clause) and have access to the decrypted version for edits once I've got that row's id.