当前位置:网站首页>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;
}
}
}
边栏推荐
- 归并排序
- Njupt Nanyou Discrete Mathematics_ Experiment 2
- 【Pygame小游戏】剧情流推荐:什么样的游戏才能获得大家的喜欢呢?(魔鬼恋人、霸总娇妻版)
- 【Pygame合集】滴~穿越童年游戏指南 请查收:这里面有你玩过的游戏嘛?(附五款源码自取)
- csdn每日一练——找出最接近元素并输出下标
- 选择排序
- 【自动回复or提醒小助手】妈妈再也不用担心我漏掉消息了(10行代码系列)
- [opencv practice] in cold winter, there will be a rainbow. Do you love this special effect?
- 2022年高考量化卷|请各位量化考生答题
- Unity自定义文件夹图标颜色 个性化Unity编译器
猜你喜欢

Website online customer service system Gofly source code development log - 5 Gin framework integration daemon

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

【JVM】线程
![[auto reply Script] happy new year. I typed every word myself, not forwarded it~](/img/53/75d2bbbee653a41e206ebd751fdea1.png)
[auto reply Script] happy new year. I typed every word myself, not forwarded it~
![[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合集】回忆杀-“童年游戏”,看看你中几枪?(附五款源码自取)

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

How to check the variable waveform when debugging the program? Look here

Bluetooth development (11) -- ble interacts happily
随机推荐
第一章 总论-会计基础
Things about Bluetooth development (1) -- starting with packet capturing data
【数据库】Nosql数据库的种类
Struggle, programmer -- Chapter 56: hard work with thousands of blows
数据库表结构
After deepin20 menu startup option, the self-test indicates that iwlwwifi is stopped
静态方法static学习
Njuptn Nanyou Discrete Mathematics_ Experiment 4
Wireshake introduction learning notes
Compared with the "South-to-North Water Transfer", what will the "east to west" of the fire bring to cloud computing?
Redis installation and common problem solving based on centeros7 (explanation with pictures)
2022年高考量化卷|请各位量化考生答题
启牛学堂理财可靠吗,安全吗
Is it safe for changtou school to open an account? Is it reliable?
安全生产月,黄埔开展燃气安全进商铺宣传活动
【Pygame小游戏】剧情流推荐:什么样的游戏才能获得大家的喜欢呢?(魔鬼恋人、霸总娇妻版)
MySQL command line import and export data
什么是绝对和相对路径,有哪些优缺点?
Basic operation of OpenCV actual combat image: this effect amazed everyone (with code analysis)
Several common current transformer sampling circuits