I am trying to connect up a Java application with a web application (in PHP), where a person can register a user on either the Java application, or on the web application. I'm trying to find the equivalent of the PHP "hash" function in Java.
For creating the hash in the web app, this is the code I use:
$salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647));
$password = hash('sha256', $_POST['password'] . $salt);
for($round = 0; $round < 65536; $round++) {
$password = hash('sha256', $password . $salt);
}
The encrypted password and salt get stored in their own columns with the user, a little bit like this:
|=====|==========|============|==========|
| ID | Username | Password | Salt |
| 1 | Bob | x24da0el.. | 39bbc9.. |
|=====|==========|============|==========|
I've tried everything and I can't get find the same method in Java.