Z
Z
Zagir Majidov2022-02-12 11:49:00
Java
Zagir Majidov, 2022-02-12 11:49:00

What does this Java code do?

I was provided with this code from the site in order to check for a correctly installed Java JDK, but this code seems a little dangerous to me.
THE CODE:

import java.security.MessageDigest;

public class Test {
    public static void main(String[] args) throws Exception {
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] digest = md.digest("Hello, JM.".getBytes("UTF-8"));
        for (byte b : digest) {
            System.out.printf("%02x", b);
        }
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Roo, 2022-02-12
@xez

digest()
Completes the hash computation by performing final operations such as padding. The digest is reset after this call is made.

C
Chevios, 2022-02-18
@Chevios

0b7b19a08983df20edbfaaa8fe60b428

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question