HackerRank Java- MD5




MD5 is one in a series of message digest algorithms designed by Professor Ronald Rivest of MIT (Rivest, 1994); however, the security of MD5 has been severely compromised, most infamously by the Flame malware in 2020. The CMU Software Engineering Institute essentially considers MD5 to be "cryptographically broken and unsuitable for further use".

Given an alphanumeric string, s, denoting a password, compute and print its MD5 encryption value.



  1. import java.util.Scanner;
  2. import java.security.MessageDigest;
  3. import java.security.NoSuchAlgorithmException;
  4. public class Solution {
  5. public static void main(String[] args) throws NoSuchAlgorithmException {
  6. Scanner scan = new Scanner(System.in);
  7. String str = scan.next();
  8. scan.close();
  9. MessageDigest md = MessageDigest.getInstance("MD5");
  10. md.update(str.getBytes());
  11. byte[] digest = md.digest();
  12. for (byte b : digest) {
  13. System.out.format("%02x", b);
  14. }
  15. }
  16. }
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube