File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Import statements for classes that are used in the code
12import java .io .*;
23import java .util .*;
34import java .security .MessageDigest ;
45import java .util .Scanner ;
56
6- // Java 15
7-
7+ // Define the public class that contains the main method
88public class Solution {
99
10+ // Main method that is executed when the program is run
1011 public static void main (String [] args ) {
11- /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
12+
13+ // Create a new Scanner object to read input from standard input (keyboard)
1214 Scanner sc = new Scanner (System .in );
15+
16+ // Read a single string from the user and store it in the 'str' variable
1317 String str = sc .next ();
18+
19+ // Close the scanner to free up system resources
1420 sc .close ();
21+
22+ // Use a try-catch block to handle any exceptions that might be thrown
1523 try {
24+
25+ // Create a new MessageDigest object that uses the MD5 algorithm
1626 MessageDigest md = MessageDigest .getInstance ("MD5" );
27+
28+ // Update the MessageDigest object with the bytes of the input string
1729 md .update (str .getBytes ());
18- // return bytesToHex(md.digest
30+
31+ // Get the resulting digest as a byte array
1932 byte [] digest = md .digest ();
33+
34+ // Loop through the byte array and print each byte as a hexadecimal string
2035 for (byte b : digest ) {
2136 System .out .printf ("%02x" , b );
2237 }
38+
39+ // Catch any exceptions that might be thrown and re-throw them as a RuntimeException
2340 } catch (Exception ex ) {
2441 throw new RuntimeException (ex );
2542 }
2643 }
2744}
2845
29- // Have a fantastic day.
You can’t perform that action at this time.
0 commit comments