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.util.Scanner;importjava.security.MessageDigest;importjava.security.NoSuchAlgorithmException;publicclassSolution{publicstaticvoidmain(String[]args)throwsNoSuchAlgorithmException{/* Read and save the input String */Scannerscan=newScanner(System.in);Stringstr=scan.next();scan.close();/* Encode the String using MD5 */MessageDigestmd=MessageDigest.getInstance("MD5");md.update(str.getBytes());byte[]digest=md.digest();/* Print the encoded value in hexadecimal */for(byteb:digest){System.out.format("%02x",b);}}}
Let me know if you have any questions.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java MD5
You are viewing a single comment's thread. Return to all comments →
Java solution - passes 100% of test cases
From my HackerRank solutions.
Use MessageDigest to do the encryption.
Let me know if you have any questions.