java:java
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
java:java [2022/07/26 08:21] – [Thread pools] admin | java:java [2024/05/31 05:22] (current) – [Random in Java] admin | ||
---|---|---|---|
Line 401: | Line 401: | ||
// so add 1 to make it inclusive | // so add 1 to make it inclusive | ||
ThreadLocalRandom.current().nextInt(min, | ThreadLocalRandom.current().nextInt(min, | ||
+ | </ | ||
+ | ==== Md5 ==== | ||
+ | <code java> | ||
+ | import java.util.HashMap; | ||
+ | import java.security.MessageDigest; | ||
+ | public static String md5(String original) { | ||
+ | try{ | ||
+ | MessageDigest md = MessageDigest.getInstance(" | ||
+ | md.update(original.getBytes()); | ||
+ | byte[] digest = md.digest(); | ||
+ | StringBuffer sb = new StringBuffer(); | ||
+ | for (byte b : digest) { | ||
+ | sb.append(String.format(" | ||
+ | } | ||
+ | return sb.toString(); | ||
+ | }catch(Exception e){ | ||
+ | return ""; | ||
+ | } | ||
+ | } | ||
</ | </ | ||
==== Java Reflection ==== | ==== Java Reflection ==== |
java/java.1658823704.txt.gz · Last modified: 2022/10/29 16:15 (external edit)