当前位置:网站首页>工具类总结
工具类总结
2022-08-05 00:43:00 【周雨彤的小迷弟】
MD5加密工具类:
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"));
}
}
ResponseUtil :
写出 response 流
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class ResponseUtil {
public static void out(HttpServletResponse response, R r) {
ObjectMapper mapper = new ObjectMapper();
response.setStatus(HttpStatus.OK.value());
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
try {
mapper.writeValue(response.getWriter(), r);
} catch (IOException e) {
e.printStackTrace();
}
}
}
边栏推荐
- oracle创建表空间
- leetcode:269. 火星词典
- 2022 Multi-school Second Session K Question Link with Bracket Sequence I
- 2022杭电多校第三场 L题 Two Permutations
- 机器学习(公式推导与代码实现)--sklearn机器学习库
- gorm的Raw与scan
- "WEB Security Penetration Testing" (28) Burp Collaborator-dnslog out-band technology
- tiup telemetry
- Software testing interview questions: Please draw the seven-layer network structure diagram of OSI and the four-layer structure diagram of TCP/IP?
- 2022牛客多校训练第二场 J题 Link with Arithmetic Progression
猜你喜欢
随机推荐
DHCP的工作过程
E - Many Operations (bitwise consideration + dp thought to record the result after the operation
2022 Hangzhou Electric Power Multi-School Session 3 Question L Two Permutations
Software testing interview questions: the difference and connection between black box testing, white box testing, and unit testing, integration testing, system testing, and acceptance testing?
翁恺C语言程序设计网课笔记合集
Software testing interview questions: How many types of software are there?
金九银十面试跳槽季;你准备好了吗?
2022 Nioke Multi-School Training Session H Question H Take the Elevator
动态规划/背包问题总结/小结——01背包、完全背包
leetcode:266. 回文全排列
阶段性测试完成后,你进行缺陷分析了么?
软件基础的理论
ora-01105 ora-03175
软件测试面试题:什么是软件测试?软件测试的目的与原则?
TinyMCE disable escape
2022多校第二场 K题 Link with Bracket Sequence I
软件测试面试题:一套完整的测试应该由哪些阶段组成?
倒计时1天!8月2日—4日与你聊聊开源与就业那些事!
刘润直播预告 | 顶级高手,如何创造财富
软件测试面试题:系统测试的策略有?









