I have two methods in Java and I want to do the same methods in php. I don't know absolutely nothing in php. How can I do it?
Method 1:
public static String encyptPassword (String in) throws UnsupportedEncodingException, NoSuchAlgorithmException{
byte[] bytes=in.getBytes("UTF-8");
MessageDigest md=MessageDigest.getInstance(MGF1ParameterSpec.SHA1.getDigestAlgorithm());
md.update(bytes);
byte[] digest=md.digest();
return toHex(digest);
}
Method 2:
public static String toHex(byte[] bytes) {
BigInteger bi = new BigInteger(1, bytes);
return String.format("%0" + (bytes.length << 1) + "x", bi);
}
The methods (function?) in php must have the same result as in java, because it's hashing passwords for a working and online login system.
I'm trying it about 3 hours, but I can't do it or found a solution. I think I read all posts on Stack. Can you help me? Thanks.