I have some php code to encrypt a message to webservice. Now, I want to create the equivalent java code but get stuck. Please help
--PHP Code looks like
$length = 60;
$salt = "MySalt";
$interation = 3000;
$bytes = openssl_pbkdf2("mypasspharse", $salt, $length, $interation, "sha1");
$value1 = substr($bytes, 0, 10);
$value2 = substr($bytes, 10, 20);
$value3 = substr($bytes, 30, 30);
return array('value1' => $value1, 'value2' => $value2, 'value3' => $value3);
--
I am trying to do the same thing in java using SecretKeyFactory. My java code looks like:
SecretKeyFactory factory = SecretKeyFactory
.getInstance("PBKDF2WithHmacSHA1");
PBEKeySpec spec = new PBEKeySpec(passphrase.toCharArray(),
salt.getBytes("UTF-8"), interation, length);
Now I don't know how could I get the equivalent $value1, $value2, $value3 as php code. Also, Im not sure that I am doing the correct way to write the equivalent java code with the php code above. Any idea is very appreciated.
Thank you,