package com.gt.utils;
import java.util.ArrayList;
import java.util.List;
public class Des {
public Des() {
}
public static void main(String[] args) {
Des desObj = new Des();
String key1 = "1";
String key2 = "2";
String key3 = "3";
String data = "admin";
String str = desObj.strEnc(data, key1, key2, key3);
System.out.println(str);
String dec = desObj.strDec(str, key1, key2, key3);
System.out.println(dec);
}
/**
* DES加密/解密
*
* @Copyright Copyright (c) 2006
* @author Guapo
* @see DESCore
*/
/*
* encrypt the string to string made up of hex return the encrypted string
*/
public String strEnc(String data, String firstKey, String secondKey,
String thirdKey) {
int leng = data.length();
String encData = "";
List firstKeyBt = null, secondKeyBt = null, thirdKeyBt = null;
int firstLength = 0, secondLength = 0, thirdLength = 0;
if (firstKey != null && firstKey != "") {
firstKeyBt = getKeyBytes(firstKey);
firstLength = firstKeyBt.size();
}
if (secondKey != null && secondKey != "") {
secondKeyBt = getKeyBytes(secondKey);
secondLength = secondKeyBt.size();
}
if (thirdKey != null && thirdKey != "") {
thirdKeyBt = getKeyBytes(thirdKey);
thirdLength = thirdKeyBt.size();
}
if (leng > 0) {
if (leng < 4) {
int[] bt = strToBt(data);
int[] encByte = null;
if (firstKey != null && firstKey != "" && secondKey != null
&& secondKey != "" && thirdKey != null
&& thirdKey != "") {
int[] tempBt;
int x, y, z;
tempBt = bt;
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "" && secondKey != null
&& secondKey != "") {
int[] tempBt;
int x, y;
tempBt = bt;
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "") {
int[] tempBt;
int x = 0;
tempBt = bt;
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
encByte = tempBt;
}
}
}
encData = bt64ToHex(encByte);
} else {
int iterator = (leng / 4);
int remainder = leng % 4;
int i = 0;
for (i = 0; i < iterator; i++) {
String tempData = data.substring(i * 4 + 0, i * 4 + 4);
int[] tempByte = strToBt(tempData);
int[] encByte = null;
if (firstKey != null && firstKey != "" && secondKey != null
&& secondKey != "" && thirdKey != null
&& thirdKey != "") {
int[] tempBt;
int x, y, z;
tempBt = tempByte;
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != ""
&& secondKey != null && secondKey != "") {
int[] tempBt;
int x, y;
tempBt = tempByte;
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "") {
int[] tempBt;
int x;
tempBt = tempByte;
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt
.get(x));
}
encByte = tempBt;
}
}
}
encData += bt64ToHex(encByte);
}
if (remainder > 0) {
String remainderData = data.substring(iterator * 4 + 0,
leng);
int[] tempByte = strToBt(remainderData);
int[] encByte = null;
if (firstKey != null && firstKey != "" && secondKey != null
&& secondKey != "" && thirdKey != null
&& thirdKey != "") {
int[] tempBt;
int x, y, z;
tempBt = tempByte;
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != ""
&& secondKey != null && secondKey != "") {
int[] tempBt;
int x, y;
tempBt = tempByte;
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
encByte = tempBt;
} else {
if (
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
源码简介: LaySSH是一款完全开源免费的开发框架,基于LayUI+SpringMVC+Spring+Hibernate+Mysql搭建而成,内置代码生成器,能够快速生成增删改查代码,节省开发时间,快速构建企业级的web应用系统。 该框架具备一整套完整的权限管理系统,代码简洁,容易入门,方便您进行二次开发
资源推荐
资源详情
资源评论
收起资源包目录
基于ssh+layui的java快速开发框架源码 (591个子文件)
MenuInfServiceImpl.class 22KB
CodeGeneratorByMysqlByLayUIServiceImpl.class 20KB
Des.class 20KB
ByteHandleImpl.class 19KB
InsInfServiceImpl.class 15KB
RoleInfServiceImpl.class 14KB
OperInfServiceImpl.class 14KB
PbUtils.class 11KB
OperInfController.class 11KB
BaseDaoThreadImpl.class 11KB
BaseDaoImpl.class 10KB
SysFunctionInfServiceImpl.class 10KB
DictCdServiceImpl.class 10KB
FileHandle.class 9KB
BaseController.class 9KB
ExportExcelController.class 9KB
MD5.class 8KB
MenuInfController.class 8KB
QuarzServiceImpl.class 7KB
BaseServiceImpl.class 7KB
SysLogServiceImpl.class 6KB
NoInterceptorServiceImpl.class 6KB
RoleInfController.class 6KB
TSysInsInf.class 6KB
DictTpServiceImpl.class 6KB
AuthInterceptor.class 6KB
StudentServiceImpl.class 6KB
TSysOperInf.class 5KB
InsInfController.class 5KB
GetFileName.class 5KB
MapToBeanUtils.class 5KB
DictCdController.class 5KB
RoleFunctionServiceImpl.class 4KB
MapToBeanUtils2.class 4KB
QuarzController.class 4KB
SysFunctionInfController.class 4KB
OperInf.class 4KB
TSysRoleInf.class 4KB
StudentController.class 4KB
TSysMenuInf.class 4KB
SessionInterceptor.class 4KB
RandomValidateCode.class 4KB
MyBeanUtils.class 4KB
DictTpController.class 4KB
FileUploadController.class 4KB
QuarzUtils.class 4KB
NoInterceptorController.class 4KB
InsInf.class 4KB
Timer.class 4KB
UserInfo.class 4KB
FileMD5.class 4KB
TemplateParams.class 3KB
Student.class 3KB
ReadFile.class 3KB
TSysLog.class 3KB
TSysFunctionInf.class 3KB
MenuInf.class 3KB
CodeGeneratorController.class 3KB
TemplateHelp.class 3KB
QuartzInItServlet.class 3KB
ButtonCreateController.class 3KB
Quarz.class 3KB
PropertiesUtils.class 3KB
SysCacheProcessImpl.class 3KB
RoleFunctionController.class 3KB
SysLog.class 3KB
IBaseService.class 2KB
IBaseDao.class 2KB
DictCacheProcessImpl.class 2KB
DataConverter.class 2KB
TSysDictTp.class 2KB
BaseQuartz.class 2KB
RoleOperServiceImpl.class 2KB
TSysDictCd.class 2KB
MenutCacheProcessImpl.class 2KB
TreeForLayUI.class 2KB
MenuForLayUI.class 2KB
TSysRoleOper.class 2KB
TSysRoleFunction.class 2KB
RoleInf.class 2KB
ParseProperties.class 2KB
TSysNointerceptor.class 2KB
CacheInterceptor.class 2KB
DictCd.class 2KB
ImageServlet.class 2KB
IMenuInfService.class 2KB
EncodingInterceptor.class 2KB
CharUtils.class 1KB
Contans.class 1KB
TableFields.class 1KB
DatagridForLayUI.class 1KB
SysFunctionInf.class 1KB
GetIpUtil.class 1KB
SysLogController.class 1KB
ZTree.class 1KB
BasePageForLayUI.class 1KB
Json.class 1KB
Function.class 1KB
IRoleInfService.class 1KB
ISysFunctionInfService.class 1KB
共 591 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- zjtyuqilin2023-11-15不错,配置简单,断网环境下开发利器
持续航行
- 粉丝: 4
- 资源: 84
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功