当前位置:网站首页>工具类总结
工具类总结
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();
}
}
}
边栏推荐
- 2022 Hangzhou Electric Power Multi-School Session 3 K Question Taxi
- could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
- leetcode: 269. The Martian Dictionary
- GO中sync包自由控制并发的方法
- 机器学习(公式推导与代码实现)--sklearn机器学习库
- 翁恺C语言程序设计网课笔记合集
- [230] Execute command error after connecting to Redis MISCONF Redis is configured to save RDB snapshots
- tiup uninstall
- could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
- 2022 The Third J Question Journey
猜你喜欢
oracle create tablespace
could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
倒计时1天!8月2日—4日与你聊聊开源与就业那些事!
"WEB Security Penetration Testing" (28) Burp Collaborator-dnslog out-band technology
进程间通信和线程间通信
《WEB安全渗透测试》(28)Burp Collaborator-dnslog外带技术
活动推荐 | 快手StreamLake品牌发布会,8月10日一起见证!
redis可视化管理软件Redis Desktop Manager2022
MongoDB搭建及基础操作
TinyMCE禁用转义
随机推荐
"No title"
软件测试面试题:软件验收测试的合格通过准则?
动态规划/背包问题总结/小结——01背包、完全背包
JUC线程池(一): FutureTask使用
TinyMCE disable escape
软件测试面试题:系统测试的策略有?
进程间通信和线程间通信
E - Many Operations (bitwise consideration + dp thought to record the result after the operation
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?
tensor.nozero(),面具,面具
2022杭电多校第一场 1004 Ball
tiup status
软件测试面试题:设计测试用例时应该考虑哪些方面,即不同的测试用例针对那些方面进行测试?
leetcode:266. 回文全排列
典型相关分析CCA计算过程
oracle create tablespace
redis可视化管理软件Redis Desktop Manager2022
翁恺C语言程序设计网课笔记合集
【idea】idea配置sql格式化
活动推荐 | 快手StreamLake品牌发布会,8月10日一起见证!