Hacker rank 56th solution java(java md5)

56. JAVA MD5

// MD5 IS A TECHNIQUE FOR ENCRYPTION


 import java.security.MessageDigest;
import java.util.Scanner;

public class Solution {

    public static void main(String[] argh) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        sc.close();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes());
            // return bytesToHex(md.digest
            byte[] digest = md.digest();
            for (byte b : digest) {
                System.out.printf("%02x", b);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}


Compiler Message
Success
Input (stdin)Download
HelloWorld
{-truncated-}
Download to view the full testcase
Expected OutputDownload
68e109f0f40ca72a15e05cc22786f8e6
{-truncated-}

Comments

Popular posts from this blog

Amazon Web Services

Google Code-In mentorship experience :)

Hacker Rank all java and python problem solutions