当前位置:网站首页>MD5Util
MD5Util
2022-06-11 00:12:00 【Mr. No】
package com.sinosoft.platform.common.util;
import lombok.extern.slf4j.Slf4j;
import java.security.MessageDigest;
/**
* @Auther:hcg
* @Description:
*/
@Slf4j
public class MD5Util {
public static String md5(String content) {
// Characters for encryption
char[] md5String = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
try {
// Use the platform default character set to md5String Encoded as byte Sequence , And store the results in a new byte Array
byte[] byteInput = content.getBytes();
// Information digest is a secure one-way hash function , It receives data of any size , And output fixed length hash value
MessageDigest mdInst = MessageDigest.getInstance("MD5");
// MessageDigest Object by using update Method processing data , Use specified byte Array update summary
mdInst.update(byteInput);
// After the summary is updated, call digest() Perform hash calculation , Get the ciphertext
byte[] md = mdInst.digest();
// Convert ciphertext into 16 Hexadecimal string form
int j = md.length;
char[] str = new char[j*2];
int k = 0;
for (int i=0;i<j;i++) {
byte byte0 = md[i];
str[k++] = md5String[byte0 >>> 4 & 0xf];
str[k++] = md5String[byte0 & 0xf];
}
// Returns the encrypted string
return new String(str);
}catch (Exception e) {
log.warn(e.getMessage(),e);
return null;
}
}
}
边栏推荐
- About optimizing API interface response speed
- Lambda learning records
- 启牛学堂理财可靠吗,安全吗
- 【Pygame小遊戲】別找了,休閑遊戲專題來了丨泡泡龍小程序——休閑遊戲研發推薦
- Error report of curl import postman
- A simple understanding of B tree
- How to remove the blank at the top of listview
- [pyGame games] don't look for it. Here comes the leisure game topic - bubble dragon widget - recommendation for leisure game research and development
- 【Go语言学习】——并发编程
- [opencv practice] this seal "artifact" is awesome, saving time and improving efficiency. It is powerful ~ (complete source code attached)
猜你喜欢

【Pygame小游戏】剧情流推荐:什么样的游戏才能获得大家的喜欢呢?(魔鬼恋人、霸总娇妻版)

【JVM】垃圾回收机制

【JVM】线程

Leetcode-560 and subarray with K
![[AI card player] for the first time to see such an](/img/7b/f1965a74733e152dcc542e465112b0.png)
[AI card player] for the first time to see such an "exciting" landowner, the key factor for a high winning rate is

博文推荐|构建 IoT 应用——FLiP 技术栈简介

【漫天烟花】绚烂烟花点亮夜空也太美了叭、某程序员携带烟花秀给大家拜年啦~

【Turtle表白合集】“海底月是天上月,眼前人是心上人。”余生多喜乐,长平安~(附3款源码)

Judgment and other issues: how to determine whether the judgment of the procedure is correct?
![[opencv practice] in cold winter, there will be a rainbow. Do you love this special effect?](/img/24/40c299b023f5f8d781d11296bcf28a.png)
[opencv practice] in cold winter, there will be a rainbow. Do you love this special effect?
随机推荐
B 树的简单认识
Compared with the "South-to-North Water Transfer", what will the "east to west" of the fire bring to cloud computing?
How to check the variable waveform when debugging the program? Look here
Pseudo static setting of Typecho - starze V Club
【JVM】垃圾回收机制
Redis installation and common problem solving based on centeros7 (explanation with pictures)
【Pygame小游戏】剧情流推荐:什么样的游戏才能获得大家的喜欢呢?(魔鬼恋人、霸总娇妻版)
【JVM】类加载机制
The website is harmed by XSS hanging horse
After deepin20 menu startup option, the self-test indicates that iwlwwifi is stopped
Bluetooth development (9) -- A2DP protocol in combination with code
Struggle, programmer -- Chapter 56: hard work with thousands of blows
归并排序
phpstudy的安装
第一章 总论-会计基础
[pyGame] can the little dinosaur on chrome be played with code? It looks like fun~
Leetcode-560 and subarray with K
Njupt Nanyou Discrete Mathematics_ Experiment 1
[untitled]
yum源更新