We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;importjava.security.MessageDigest;importjava.math.BigInteger;publicclassSolution{publicstaticvoidmain(String[]args)throwsException{Scannerscan=newScanner(System.in);Stringstr=scan.nextLine();scan.close();try{// Static getInstance method is called with hashing MD5MessageDigestmd=MessageDigest.getInstance("MD5");// digest() method is called to calculate message digest// of an input digest() return array of bytebyte[]messageDigest=md.digest(str.getBytes());// Convert byte array into signum representationBigIntegerno=newBigInteger(1,messageDigest);// Convert message digest into hex valueStringhashtext=no.toString(16);while(hashtext.length()<32){hashtext="0"+hashtext;}System.out.println(hashtext);}// For specifying wrong message digest algorithmscatch(Exceptione){thrownewException(e);}}}
works well for java7, java8, java15 import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Scanner;
public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); sc.close();
}
import java.io.; import java.util.; import java.security.MessageDigest; import java.math.BigInteger;
public class Solution {
}
import java.io.; import java.util.; import java.math.BigInteger; import java.security.MessageDigest;
public class Solution {
}
(https://digitwood.com/java-md5-hacker-rank-solution-digit-wood/)