FAQ Database Discussion Community

java MD5 encryption minus value in byte array

Hello I am using below code to encrypt a string. I found MD5 make working in -127 - +128 values. I am getting value in minus for. public static void main(String[] args) throws Exception { String message = "smile"; encrypt("Jack the Bear"); } public static void encrypt(String password) throws Exception...

Generating an MD5 Hash with a char[]

How would one go about converting a char[] password obtained using this method: char[] password = passwordInputField.getPassword(); To an MD5 Hash? Normally I would use the method below, but getBytes is only compatible with Strings: MessageDigest md = MessageDigest.getInstance("MD5"); md.update(password.getBytes()); String hashedPass = new BigInteger(1, md.digest()).toString(16); ...