I'm trying to insert a hash into MySQL, so I can test user logins. My first instinct was to use phpMyAdmin to make quickly updating passwords easier (default hash is 60 0's), until I get around to making a page for doing that using my website. The hash field is a binary (60) data type. My error is Please enter a valid HEX input.
To generate the hash, I am using the following: Code Credit
$pass = "password";
$salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
$cost = 10;
$salt = sprintf("$2y$%02d$", $cost) . $salt;
$hash = crypt($pass, $salt);
echo $hash;//Result: $2y$10$XFo5biY5UvZfaRjhDraOFO26yocvwiAwidtGNIvoEezj5zitb2Xem
I already realize I am halfway to making the website do the inserts for me, but that isn't the question. I was wanting to know why phpMyAdmin > myDB > myTable > browse > edit then copy pasting the result from above does not work, however phpMyAdmin > myDB > myTable > SQL does work when using the following:
UPDATE `myTable` SET `hash`="$2y$10$XFo5biY5UvZfaRjhDraOFO26yocvwiAwidtGNIvoEezj5zitb2Xem" WHERE username = "myusername"
Going back to phpMyAdmin > myDB > myTable > browse I find that my ASCII hash has changed to the HEX hash:
2432792431302458466f356269593555765a6661526a684472614f464f3236796f637677694177696474474e49766f45657a6a357a6974623258656d
This HEX string remains the same when I do a select in phpMyAdmin, however, using the MySQL console, I never see HEX, it's always ASCII. Does anyone know why I can't insert the ASCII hash in phpMyAdmin, but I can in MySQL?
Edit: Dead link, but the WayBack Machine has a copy.