当前位置:网站首页>工具类总结
工具类总结
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();
}
}
}
边栏推荐
猜你喜欢
随机推荐
tiup status
如何用 Solidity 创建一个“Hello World”智能合约
典型相关分析CCA计算过程
tensor.nozero(),面具,面具
redis可视化管理软件Redis Desktop Manager2022
Software Testing Interview Questions: What do you think about software process improvement? Is there something that needs improvement in the enterprise you have worked for? What do you expect the idea
2022 Hangzhou Electric Power Multi-School Session 3 K Question Taxi
阶段性测试完成后,你进行缺陷分析了么?
软件测试面试题:您如何看待软件过程改进?在您曾经工作过的企业中,是否有一些需要改进的东西呢?您期望的理想的测试人员的工作环境是怎样的?
【unity编译器扩展之模型动画拷贝】
Software testing interview questions: test life cycle, the test process is divided into several stages, and the meaning of each stage and the method used?
软件测试面试题:LoadRunner 分为哪三个模块?
Software testing interview questions: What are the strategies for system testing?
2022 Multi-school Second Session K Question Link with Bracket Sequence I
tensor.nozero(), mask, [mask]
gorm联表查询-实战
软件测试面试题:请你分别画出 OSI 的七层网络结构图和 TCP/IP 的四层结构图?
Software Testing Interview Questions: What aspects should be considered when designing test cases, i.e. what aspects should different test cases test against?
2022 The Third J Question Journey
E - Many Operations (按位考虑 + dp思想记录操作后的结果