当前位置:网站首页>User password encryption tool
User password encryption tool
2022-08-03 04:40:00 【Dzooooone_】
Encryption
import org.apache.commons.codec.binary.Base64;import javax.crypto.Cipher;import javax.crypto.SecretKey;import javax.crypto.spec.SecretKeySpec;public class CryptoUtil {//Encryption Algorithmprivate static final String DESede_ALGORITHM = "DESede";//With saltprivate static final String KEY = "xxxx";/*** Text encryption** @param plain text to be encrypted* @return* @throws Exception*/public static final String encrypt(String plain) {byte[] newKeys = getKeys(KEY);try {SecretKey secureKey = new SecretKeySpec(newKeys, DESede_ALGORITHM);Cipher cipher = Cipher.getInstance(DESede_ALGORITHM);cipher.init(1, secureKey);byte[] encrypted = cipher.doFinal(plain.getBytes());return new String(Base64.encodeBase64(encrypted));} catch (Exception e) {return null;}}/*** Password decryption** @param cryptograph password to be decrypted* @return* @throws Exception*/public static final String decrypt(String cryptograph) {byte[] newKeys = getKeys(KEY);byte[] encrypted = Base64.decodeBase64(cryptograph.getBytes());try {SecretKey secureKey = new SecretKeySpec(newKeys, DESede_ALGORITHM);Cipher cipher = Cipher.getInstance(DESede_ALGORITHM);cipher.init(2, secureKey);byte[] cryptoGraphs = cipher.doFinal(encrypted);return new String(cryptoGraphs);} catch (Exception e) {return null;}}private static byte[] getKeys(String key) {byte[] oldKeys = KEY.getBytes();byte[] newKeys = new byte[24];for (int i = 0; i < oldKeys.length && i != 24; i++)newKeys[i] = oldKeys[i];return newKeys;}public static void main(String[] args) throws Exception {System.out.println(CryptoUtil.encrypt("xxxxxx"));System.out.println(CryptoUtil.decrypt("gySSNZWJIyQ="));System.out.println(CryptoUtil.decrypt("/4lOgQ80Y9LVB69nhkR1tA=="));}}Encrypt the user password first and then store it in the warehouse
jwt dependencies
io.jsonwebtoken jjwt-impl ${jjwt.version} io.jsonwebtoken jjwt-jackson ${jjwt.version} 边栏推荐
- 修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔
- rosbag工具plotjuggler无法打开rosbag的问题
- WinForm的控件二次开发
- js中的闭包
- 刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
- GIS数据漫谈(五)— 地理坐标系统
- 私域流量引流方法?分享购火爆的商业模式,你值得拥有
- Record some bugs encountered - when mapstruct and lombok are used at the same time, the problem of data loss when converting entity classes
- 13.机器学习基础:数据预处理与特征工程
- 超好用的画图工具推荐
猜你喜欢
随机推荐
接口管理工具YApi怎么用?颜值高、易管理、超好用
GIS数据漫谈(六)— 投影坐标系统
社交电商:流量红利已尽,裂变营销是最低成本的获客之道
【Harmony OS】【FAQ】鸿蒙问题合集1
在竞争白热化的电商行业,链动2+1为什么还有企业在用
How to use the interface management tool YApi?Beautiful, easy to manage, super easy to use
2022/08/02 Study Notes (day22) Multithreading
深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析
Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
寄存器(内存访问)
Kotlin-Flow常用封装类:StateFlow的使用
Bubble sort in c language structure
2022河南萌新联赛第(四)场:郑州轻工业大学 G - 迷宫
2022河南萌新联赛第(四)场:郑州轻工业大学 E - 睡大觉
常见荧光染料修饰多种基团及其激发和发射波长数据一览数据
13.机器学习基础:数据预处理与特征工程
接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
Practical application of WebSocket
6.神经网络剖析
OpenFOAM extracts equivalency and calculates area









