当前位置:网站首页>MD5 encryption tool class
MD5 encryption tool class
2022-08-08 00:22:00 【biienu】
MD5加密工具类
package com.biienu.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public final class MD5 {
public static String encrypt(String strSrc) {
try {
char hexChars[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'a', 'b', 'c', 'd', 'e', 'f' };
byte[] bytes = strSrc.getBytes();
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(bytes);
bytes = md.digest();
int j = bytes.length;
char[] chars = new char[j * 2];
int k = 0;
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
chars[k++] = hexChars[b >>> 4 & 0xf];
chars[k++] = hexChars[b & 0xf];
}
return new String(chars);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new RuntimeException("MD5加密出错!!+" + e);
}
}
public static void main(String[] args) {
System.out.println(MD5.encrypt("111111"));
}
}
边栏推荐
猜你喜欢

Distributed agreement of Lease mechanism

2021 RoboCom 世界机器人开发者大赛-本科组(决赛)7-1绿色围栏(模拟)

solidworls view and model and drawing operation shortcuts

leetcode-每日一题636. 函数的独占时间(模拟栈)

PLC运动控制系列之梯形速度曲线

Detailed explanation of SQL DNSlog injection

pinia详解

Chapter 3 Matrix Compression

继承关系下构造方法的访问特点注意:把this()访问本类其他成员方法也加进去

【目标检测】------xml操作
随机推荐
Two queues implement a stack
Is the Flush stock trading software legitimate?is it safe?
多少建模师靠着zbrush这软件成家立业,你们还在等什么
学习3dmax|怎样学习最高效率,十年建模师指点你不良习惯
【目标检测】------非极大值抑制NMS底层
我想进行炒股开户,开户安全吗
OpenFeign简介和使用详解
Mongodb出现Error: couldn‘t add user: Could not find role: [email protected] 解决方法
使用jmh框架进行benchmark测试
Introduction and detailed explanation of OpenFeign
周末放松的方式
MYSQL索引学习(高级篇,目录)
高数_证明_柯西中值定理
visual studio code中rust代码debug时中文乱码的处理【win10平台】
故障:不能打开 Office 应用程序,并指示有账户正在登录
puzzle(018.4)珍珑棋局
进程间的通信终章之【消息队列,信号量,共享内存】
机器学习的基础概念
使用开源库libyuv中替换开源汇编接口,解决汇编接口中的崩溃问题
中南大学|DL-DRL:一种用于多无人机大规模任务调度的双层深度强化学习方法