当前位置:网站首页>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;
}
}
}
边栏推荐
- Typecho blog site wide deployment of Tencent cloud CDN tutorial - Xingze V Club
- Hyperleger fabric installation
- Basic introduction and core components of kubernetes
- LabVIEW performs a serial loopback test
- [pyGame collection] memory killing - "Childhood Games", how many shots did you get? (attach five source codes for self access)
- [pyGame games] story stream recommendation: what kind of games can you like? (devil lover, bully's wife version)
- [daily] robots Txt allow all search engines to include
- Bluetooth development (6) -- literacy of Bluetooth protocol architecture
- 安全生产月,黄埔开展燃气安全进商铺宣传活动
- In the month of safety production, Huangpu launched a publicity campaign for gas safety in shops
猜你喜欢
![[pyGame] this](/img/7c/adc13c0c87ca31c8581d68e6f21363.jpg)
[pyGame] this "groundhog" game is going to be popular (come on, come on)

Basic operation of OpenCV actual combat image: this effect amazed everyone (with code analysis)

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

It is said that the verification code is a barrier in the crawler. I can break through it with only five lines of code.
![[pyGame games] here it is. This Gobang game is super A. share it with your friends~](/img/76/faea3558ed6fadff755c517922088b.png)
[pyGame games] here it is. This Gobang game is super A. share it with your friends~

From the perspective of Confucius Temple IP crossover, we can see how the six walnuts become "butterflies" for the second time

A simple understanding of B tree

Bluetooth development (3) -- look at the air bag

【 pygame Games 】 don't find, Leisure Games Theme come 丨 Bubble Dragon applet - - Leisure Games Development recommendation

In the month of safety production, Huangpu launched a publicity campaign for gas safety in shops
随机推荐
[pyGame collection] please check the game guide through childhood: are there any games you have played? (attach five source codes for self access)
csdn每日一练——找出最接近元素并输出下标
集合删除元素技巧 removeIf
When leaving the web page, the website displays 404 Not found- starze V Club
[pyGame] this classic bomber super game is online. Do you love it? (source code attached)
Why is the website snapshot hijacked and tampered with
[pyGame games] here it is. This Gobang game is super A. share it with your friends~
IGBT与三代半导体SiC双脉冲测试方案
【Pygame合集】滴~穿越童年游戏指南 请查收:这里面有你玩过的游戏嘛?(附五款源码自取)
High speed data stream disk for LabVIEW
Read it once: talk about MySQL master-slave
CSDN daily practice - find the closest element and output the subscript
Compared with the "South-to-North Water Transfer", what will the "east to west" of the fire bring to cloud computing?
yum源更新
【Go语言学习】——并发编程
Self made app connected to onenet --- realize data monitoring and distribution control (mqtt)
Kubernetes 基本介绍及核心组件
Bluetooth development (3) -- look at the air bag
Leetcode-713 subarray with product less than k
Exception 0xc00000005 code occurred when LabVIEW called DLL