Trying to create a secure login I have decided to create an MD5 hash using the following code, adapted a small bit from How can I generate an MD5 hash?
However, this doesn't generate the same hash when the user is created as is created on the login page. why is this as I thought the hash was unique to each string.
    MessageDigest messageDigest = null;
    try{
        messageDigest = MessageDigest.getInstance("MD5");
    }catch(NoSuchAlgorithmException e){
        System.out.println("Error: " + e);
    }
    messageDigest.reset();
    messageDigest.update(inPassword.getBytes());
    byte[] digest = messageDigest.digest();
    BigInteger bigInt = new BigInteger(1, digest);
    String encodedPass = bigInt.toString(16);
    while (encodedPass.length() < 32) {
        encodedPass = "0" + encodedPass;
    }
    inPassword = encodedPass;
 
     
     
     
    