当前位置:网站首页>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} 边栏推荐
- 汇编书摘抄
- How to prepare for the test interface test data
- Kotlin-Flow常用封装类:StateFlow的使用
- v-on指令:为元素绑定事件
- RequestContextHolder
- 11.机器学习基础:机器学习的四个分支
- 常见荧光染料修饰多种基团及其激发和发射波长数据一览数据
- Two ways to simulate multi-user login in Jmeter
- 刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
- How to use the interface management tool YApi?Beautiful, easy to manage, super easy to use
猜你喜欢

【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接

Interface test practice | Detailed explanation of the difference between GET / POST requests

【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability

BIOTIN ALKYNE CAS:773888-45-2价格,供应商

10.预测房价:回归问题

社交电商:链动2+1模式,为什么能在电商行业生存那么久?

接口测试实战| GET/POST 请求区别详解

【Harmony OS】【FAQ】鸿蒙问题合集1

GIS数据漫谈(六)— 投影坐标系统

mysql 创建索引的三种方式
随机推荐
探索性测试的概念及方法
寄存器(内存访问)
测试人员的价值体现在哪里
9.新闻分类:多分类问题
工程制图点的投影练习
在竞争白热化的电商行业,链动2+1为什么还有企业在用
自组织是管理者和成员的双向奔赴
接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
接口测试 Mock 实战(二) | 结合 jq 完成批量化的手工 Mock
How many moments have you experienced the collapse of electronic engineers?
The flink sql task is changed, and after adding several fields to the sql, an error occurs when restoring from the previously saved savepoint.
WebSocket的实际应用
EssilorLuxottica借助Boomi的智能集成平台实现订单处理的现代化
Windows 安装PostgreSQL
v-on指令:为元素绑定事件
mysql 创建索引的三种方式
CyberArk被评为2022年Gartner特权访问管理魔力象限领导者
GIS数据漫谈(五)— 地理坐标系统
3.张量运算
DFS's complement to pruning