当前位置:网站首页>MD5Util
MD5Util
2022-06-10 22:52:00 【號先生】
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) {
// 用于加密的字符
char[] md5String = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
try {
// 使用平台默认的字符集将md5String编码为byte序列,并将结果存储到一个新的byte数组中
byte[] byteInput = content.getBytes();
// 信息摘要是安全的单向哈希函数,它接收任意大小的数据,并输出固定长度的哈希值
MessageDigest mdInst = MessageDigest.getInstance("MD5");
// MessageDigest对象通过使用update方法处理数据,使用指定的byte数组更新摘要
mdInst.update(byteInput);
//摘要更新后通过调用digest() 执行哈希计算,获得密文
byte[] md = mdInst.digest();
//把密文转换成16进制的字符串形式
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];
}
// 返回加密后的字符串
return new String(str);
}catch (Exception e) {
log.warn(e.getMessage(),e);
return null;
}
}
}
边栏推荐
- 选择排序
- 【Go语言学习】——并发编程
- 452. 用最少数量的箭引爆气球
- IGBT and third generation semiconductor SiC double pulse test scheme
- 【自动回复or提醒小助手】妈妈再也不用担心我漏掉消息了(10行代码系列)
- Top ten information security principles
- How to remove the blank at the top of listview
- LabVIEW displays the time and date on the waveform chart or waveform chart
- vtk.js中vtp下载
- 【Pygame小游戏】剧情流推荐:什么样的游戏才能获得大家的喜欢呢?(魔鬼恋人、霸总娇妻版)
猜你喜欢

Several common current transformer sampling circuits

LabVIEW pictures look bright or dark after being cast from 16 bits to 8 bits

Redis installation and common problem solving based on centeros7 (explanation with pictures)

【Pygame合集】回忆杀-“童年游戏”,看看你中几枪?(附五款源码自取)
![[turtle confessions collection]](/img/81/b4bacc23691e58e403f1330d0ca7cf.jpg)
[turtle confessions collection] "the moon at the bottom of the sea is the moon in the sky, and the person in front of us is the sweetheart." Be happy for the rest of your life, and be safe for ever ~
![[appearance detection artifact] come on, please show me your unique skill (is this appearance worthy of the audience?)](/img/c4/b571bec5fe0cd2968e078a8231d0bd.png)
[appearance detection artifact] come on, please show me your unique skill (is this appearance worthy of the audience?)

【Pygame小游戏】不怕你走不过系列:极致AI走迷宫,学习完带你打开新世界大门~(附游戏源码)

Difference between oscilloscope and spectrum analyzer

Bluetooth development (2) -- initialization

yum源更新
随机推荐
Openresty installation
A simple understanding of B tree
选择排序
[fireworks in the sky] it's beautiful to light up the night sky with gorgeous fireworks. A programmer brought a fireworks show to pay New Year's greetings to everyone~
[pyGame] this classic bomber super game is online. Do you love it? (source code attached)
How to remove the blank at the top of listview
Multipartfile rename upload
From the perspective of Confucius Temple IP crossover, we can see how the six walnuts become "butterflies" for the second time
MP框架基本操作(自用)
【Pygame小游戏】剧情流推荐:什么样的游戏才能获得大家的喜欢呢?(魔鬼恋人、霸总娇妻版)
【Turtle表白合集】“海底月是天上月,眼前人是心上人。”余生多喜乐,长平安~(附3款源码)
Is the financial management of qiniu school reliable and safe
【AcWing】4. Multiple knapsack problem I
C language file operation
csdn每日一练——找出最接近元素并输出下标
Leetcode-15 sum of three numbers
Merge sort
【Pygame小游戏】激荡大脑思维,一起来玩转奇思妙想“24点”叭~(超赞滴)
phpstudy的安装
[pyGame games] here it is. This Gobang game is super A. share it with your friends~