The application takes several inputs (notably, private personal informations) to produce a fixed, but non-guessable hash.
Simplified example:
$data = $websiteDomain . $myChildSchool . $myPetName . $etc;
for ($i = 0; $i < 1000000; ++$i) {
$data = hash('sha512', $data, true);
}
$data = str_replace(['/', '+', '='], '', base64_encode($data));
$result = substr($data, 0, $passwordLength);
The goal is to create a publicly published code, that generates hashes that are then used as passwords. And the important part: the passwords can be recovered, using the public code and the private personal information.
Because of this, I can't use password_hash()
because the result is automatically salted so it produces different hashes each time. I can't manually provide a salt as it is deprecated (produces warning, and likely to be removed in future PHP versions).
My main concern is that some of the passwords could be used on crappy websites, that have small maxlength restrictions, and store the user passwords as plaintext. Thus, I'm assuming attackers could steal the hashed data from the website, and use brute force to deduce back the private data.
In the above example I'm using SHA-512 with key stretchingkey stretching. Though, SHA isn't really designed for this, GPUs are incredibly fast on it, and there may exist, now or later, techniques to circumvent all or part of the iterations.
So, how acceptable is the current technique? Could it be improved, and if so, how? Ideally, the solution shouldn't be PHP-specific, and shouldn't require external libraries.