php - Sanitizing password_hash() strings -
I have to help with a safe and future-forward way to sanitize hash strings that are basically password_hash ()
.
password_hash ()
The default algorithm on my system will be implemented with PASSWORD_DEFAULT integer, which will be bcrypt ()
encryption, though it will be the future of PHP Can be changed in versions.
I have read that any of the manual pages clearly shows which characters can be generated by this algorithm.
Will someone at least suggest sanitaryization which will work? Maybe ...
filter_var ($ hashed password, FILTER_SANITIZE_STRING);
or
preg_replace ('/ ^ [a-zA-Z0-9 - \ $ \ =] * $ /', '', $ Hashed password);
If you have a specific BCRPT, but do not necessarily have a change in the PHL in the future and I have to update my Reggae string in the future, it's OK to break, Tell me and I will consider it
Thanks for any help.
P.S. If you are wondering why do not bother them, okay because it is passing a little bit in the two systems due to some system migration, we are doing from one system to another and if it comes from another system, The function does not sanitize the input.
OK, password_hash ()
Basically a good implementation of the bus crypt ()
function by default, using Blowfish algorithms,
crypt ('somepassword', '$ 2y $ 10 $ randomly generated $') ;; The function returns a string that looks like this: $ 2y $ 10 $ random form Can be generated from 2 DDLVP 1Ii2e / U9C8sBjqp8I90dH6hi < - Algorithm
- Cost Li> Salt / hash combination
(emphasis is mine):
[...] with salt Blowfish hashing is as follows: "$ 2a $", "$ 2x $" or "$ 2y $", a two-digit cost parameter, "$" and 22 characters alphabetically ".0-9-a-Za -z ". > [...] The two-digit cost parameter [...] should be in the range 04-31 [...] The hash is a base 64 encoded string using the < Code>.
and /
as two final characters. In other words, a hash generated by password_hash ()
includes:
[a-zA-Z0-9 $ /. ]
And it is 60 characters long.
I do not know why you want to consolidate it (a hash should never have been modified, so there should be no sensitization), but something like this should be done:
$ sanitized = filter_var ($ hash, FILTER_CALLBACK, ['options' = & gt; function ($ hash) {return preg_replace (' / [^ a-zA-Z0-9 $ \ /.] / ',' ', $ Hash);}]);
Comments
Post a Comment