To provide some assurance that a transferred file has arrived intact.<\/li><\/ul>\n\n\n\nMD5 is one in a series of message digest algorithms designed by Professor Ronald Rivest of MIT (Rivest, 1994<\/strong>); however, the security of MD5 has been severely compromised, most infamously by the Flame malware in 2012<\/strong>. The CMU Software Engineering Institute essentially considers MD5 to be “cryptographically broken and unsuitable for further use”.
Given an alphanumeric string, s<\/strong>, denoting a password, compute and print its MD5 encryption value.<\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nA single alphanumeric string denoting s<\/strong>.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h4>\n\n\n\n- 6 <= |s| <= 20<\/strong><\/li>
- String s <\/strong>consists of English alphabetic letters (i.e.,[a-z A-Z]<\/strong> and\/or decimal digits (i.e.,0<\/strong> through 9<\/strong>) only.<\/li><\/ul>\n\n\n\n
<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\nPrint the MD5 encryption value of s <\/strong>on a new line.<\/p>\n\n\n\n<\/span>Sample Input 0<\/strong><\/span><\/h4>\n\n\n\n HelloWorld<\/code><\/pre>\n\n\n\n<\/span>Sample Output 0<\/strong><\/span><\/h4>\n\n\n\n 68e109f0f40ca72a15e05cc22786f8e6<\/code><\/pre>\n\n\n\n<\/span>Sample Input 1<\/strong><\/span><\/h4>\n\n\n\n Javarmi123<\/code><\/pre>\n\n\n\n<\/span>Sample Output 1<\/strong><\/span><\/h4>\n\n\n\n 2da2d1e0ce7b4951a858ed2d547ef485<\/code><\/pre>\n\n\n\n<\/span>Solution – Java MD5<\/strong><\/span><\/h2>\n\n\n\nimport java.util.Scanner;\nimport java.security.MessageDigest;\nimport java.security.NoSuchAlgorithmException;\n\npublic class Solution {\n public static void main(String[] args) throws NoSuchAlgorithmException {\n \/* Read and save the input String *\/\n Scanner scan = new Scanner(System.in);\n String str = scan.next();\n scan.close();\n \n \/* Encode the String using MD5 *\/\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.update(str.getBytes());\n byte[] digest = md.digest();\n \n \/* Print the encoded value in hexadecimal *\/\n for (byte b : digest) {\n System.out.format(\"%02x\", b);\n }\n }\n}<\/pre>\n\n\n\n