M
M
MakarMS2020-05-09 20:37:57
Java
MakarMS, 2020-05-09 20:37:57

How to encode a string in Java?

Hello, I have a problem. I want to encrypt a string in MD5 but don't know how). On the Internet, I rummaged through a bunch of sites and forums, and not one of them is explained in such a way that a beginner would understand. Can you give an example of code for MD5 encryption of the string String a = "habr"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2020-05-09
@MakarMS

Somehow you dug badly, google gives almost 12 million results for the query "java md5".

MessageDigest md = MessageDigest.getInstance("MD5");
md.update(a.getBytes());
byte[] digest = md.digest();

PS MD5 is not encryption, but hashing.

I
Ivan Ivanov, 2020-05-09
@maksim_fix

Google badly, https://javadevblog.com/prymer-heshyrovanyya-md5-v...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question