前端正则生成功能

md5加解密功能
pull/254/head
xjs 3 years ago
parent eac6deb84e
commit 4287429779

@ -13,6 +13,7 @@
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。 若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
(xjs专用版) 若依28900行代码 (xjs专用版) 若依28900行代码
数据库文件在本机电脑上
* 采用前后端分离的模式,微服务版本前端(基于 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue))。 * 采用前后端分离的模式,微服务版本前端(基于 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue))。
* 后端采用Spring Boot、Spring Cloud & Alibaba。 * 后端采用Spring Boot、Spring Cloud & Alibaba。
@ -128,4 +129,4 @@ com.ruoyi
## 若依微服务交流群 ## 若依微服务交流群
QQ群 [![加入QQ群](https://img.shields.io/badge/已满-42799195-blue.svg)](https://jq.qq.com/?_wv=1027&k=yqInfq0S) [![加入QQ群](https://img.shields.io/badge/已满-170157040-blue.svg)](https://jq.qq.com/?_wv=1027&k=Oy1mb3p8) [![加入QQ群](https://img.shields.io/badge/已满-130643120-blue.svg)](https://jq.qq.com/?_wv=1027&k=rvxkJtXK) [![加入QQ群](https://img.shields.io/badge/已满-225920371-blue.svg)](https://jq.qq.com/?_wv=1027&k=0Ck3PvTe) [![加入QQ群](https://img.shields.io/badge/已满-201705537-blue.svg)](https://jq.qq.com/?_wv=1027&k=FnHHP4TT) [![加入QQ群](https://img.shields.io/badge/236543183-blue.svg)](https://jq.qq.com/?_wv=1027&k=qdT1Ojpz) 点击按钮入群。 QQ群 [![加入QQ群](https://img.shields.io/badge/已满-42799195-blue.svg)](https://jq.qq.com/?_wv=1027&k=yqInfq0S) [![加入QQ群](https://img.shields.io/badge/已满-170157040-blue.svg)](https://jq.qq.com/?_wv=1027&k=Oy1mb3p8) [![加入QQ群](https://img.shields.io/badge/已满-130643120-blue.svg)](https://jq.qq.com/?_wv=1027&k=rvxkJtXK) [![加入QQ群](https://img.shields.io/badge/已满-225920371-blue.svg)](https://jq.qq.com/?_wv=1027&k=0Ck3PvTe) [![加入QQ群](https://img.shields.io/badge/已满-201705537-blue.svg)](https://jq.qq.com/?_wv=1027&k=FnHHP4TT) [![加入QQ群](https://img.shields.io/badge/236543183-blue.svg)](https://jq.qq.com/?_wv=1027&k=qdT1Ojpz) 点击按钮入群。

@ -0,0 +1,19 @@
import request from '@/utils/request'
//加密
export function encryption(data) {
return request({
url: '/openapi/md5/encryption',
method: 'get',
params: data
})
}
//解密
export function decrypt(data) {
return request({
url: '/openapi/md5/decrypt',
method: 'get',
params: data
})
}

@ -0,0 +1,101 @@
<template>
<div class="app-container">
<el-card shadow="hover">
<div slot="header" class="clearfix">
<span>MD5解密说明</span>
</div>
<ul style="font-size: 13px;color: #999999">
<li>MD5再次申明没有解密的方法最好的反驳就是数据源是无穷尽的 MD5密文是有限的</li>
<li>本工具是采用先加密存储然后再反查询上千 PB 级别毫秒级响应</li>
<li>16 MD5和32位 MD5区别是取的是8~24</li>
<li>目前 MD5 数据正在拓展拓展一个量级会同步到工具中来</li>
</ul>
</el-card>
<el-row :gutter="50" style="margin-top: 20px">
<el-col :span="12">
<at-input v-model="SourceValue" placeholder="请输入" size="large" :maxlength="20" append-button>
<template slot="append">
<i class="icon icon-search" @click="encryption"></i>
</template>
</at-input>
</el-col>
<el-form :inline="true">
<el-col :span="6">
<el-form-item label="32位">
<at-input v-model="targetValue32"></at-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="16位">
<at-input v-model="targetValue16"></at-input>
</el-form-item>
</el-col>
</el-form>
</el-row>
<el-row :gutter="50" style="margin-top: 20px">
<el-col :span="24">
<at-input v-model="md5Value" placeholder="请输入" size="large" :maxlength="32" append-button>
<template slot="append">
<i class="icon icon-search" @click="decrypt"></i>
</template>
</at-input>
</el-col>
</el-row>
</div>
</template>
<script>
import {decrypt, encryption} from "@/api/business/tools/md5";
export default {
name: "index",
data() {
return {
SourceValue: null,
targetValue16: null,
targetValue32: null,
md5Value: '',
//
decryptValue: null,
}
},
methods: {
encryption() {
let data = {
str: this.SourceValue
}
encryption(data).then(res => {
this.targetValue16 = res.data.target16
this.targetValue32 = res.data.target32
this.$modal.notifySuccess("加密成功")
})
},
decrypt() {
let data = {
str: this.md5Value
}
decrypt(data).then(res => {
this.decryptValue = res.msg
this.$alert(this.decryptValue, '解密成功啦', {
confirmButtonText: '确定',
});
})
},
}
}
</script>
<style scoped>
</style>

@ -0,0 +1,286 @@
<template>
<div class="app-container">
<el-descriptions title="什么是正则表达式?">
<el-descriptions-item label="描述" contentStyle="color: #999999">
在编写处理字符串的程序或网页时经常有查找符合某些复杂规则的字符串的需要正则表达式就是用于描述这些规则的工具换句话说正则表达式就是记录文本规则的代码
</el-descriptions-item>
</el-descriptions>
<el-row :gutter="50" style="margin-top: 20px">
<div>
<el-col :span="24">常用的正则表达式</el-col>
</div>
</el-row>
<el-row :gutter="50" style="margin-top: 20px">
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('[1-9]\\d*.\\d*|0\\.\\d*[1-9]\\d*')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('[^\x00-\xff]')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('\\s')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}')">
Email地址
</at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('^((https|http|ftp|rtsp|mms)?:\\/\\/)[^\\s]+')">URL</at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('0?(13|14|15|18|17)[0-9]{9}')">()</at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('[0-9-()]{7,18}')">()</at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('-([1-9]\\d*.\\d*|0\\.\\d*[1-9]\\d*)')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('-?[1-9]\\d*')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('[1-9]\\d*.\\d*|0\\.\\d*[1-9]\\d*')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('[1-9]([0-9]{4,10})')">QQ</at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('\\d{6}')"></at-button>
</div>
</el-col>
</el-row>
<el-row :gutter="50" style="margin-top: 20px">
<el-col :span="2">
<div>
<at-button type="error" hollow
@click="print('(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)')">
IP地址
</at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('\\d{17}[\\d|x]|\\d{15}')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('\\d{4}(\\-|\\/|.)\\d{1,2}\\1\\d{1,2}')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('[1-9]\\d*')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('-[1-9]\\d*')"></at-button>
</div>
</el-col>
<el-col :span="2">
<div>
<at-button type="error" hollow @click="print('^<([a-z]+)([^<]+)*(?:>(.*)<\\/\\1>|\\s+\\/>)$')">HTML</at-button>
</div>
</el-col>
</el-row>
<el-row :gutter="50" style="margin-top: 20px">
<el-col :span="24">
<el-input
v-model="input"
>
</el-input>
</el-col>
</el-row>
<el-row :gutter="50" style="margin-top: 20px">
<el-col :span="8">
<template>
<el-table
:data="one"
style="width: 100%">
<el-table-column label="常用元字符" align="center">
<el-table-column align="center"
prop="code"
label="代码"
width="180">
</el-table-column>
<el-table-column align="center"
prop="explanation"
label="说明"
>
</el-table-column>
</el-table-column>
</el-table>
</template>
</el-col>
<el-col :span="8">
<template>
<el-table
:data="two"
style="width: 100%">
<el-table-column label="常用限定符" align="center">
<el-table-column align="center"
prop="code"
label="代码/语法"
width="180">
</el-table-column>
<el-table-column align="center"
prop="explanation"
label="说明"
>
</el-table-column>
</el-table-column>
</el-table>
</template>
</el-col>
<el-col :span="8">
<template>
<el-table
:data="three"
style="width: 100%">
<el-table-column label="常用反义词" align="center">
<el-table-column align="center"
prop="code"
label="代码/语法"
width="180">
</el-table-column>
<el-table-column align="center"
prop="explanation"
label="说明"
>
</el-table-column>
</el-table-column>
</el-table>
</template>
</el-col>
</el-row>
</div>
</template>
<script>
export default {
name: "Regex",
data() {
return {
input: '',
one: [{
code: '.',
explanation: '匹配除换行符以外的任意字符',
}, {
code: '\\w',
explanation: '匹配字母或数字或下划线',
}, {
code: '\\s',
explanation: '匹配任意的空白符',
}, {
code: '\\d',
explanation: '匹配数字',
},
{
code: '\\b',
explanation: '匹配单词的开始或结束',
},
{
code: '^',
explanation: '匹配字符串的开始',
},
{
code: '$',
explanation: '匹配字符串的结束',
},
],
two :[{
code: '*',
explanation: '重复零次或更多次',
}, {
code: '+',
explanation: '重复一次或更多次',
}, {
code: '?',
explanation: '重复零次或一次',
}, {
code: '{n}',
explanation: '重复n次',
},
{
code: '{n,}',
explanation: '重复n次或更多次',
},
{
code: '{n,m}',
explanation: '重复n到m次',
},
],
three :[{
code: '\\W',
explanation: '匹配任意不是字母,数字,下划线,汉字的字符',
}, {
code: '\\S',
explanation: '匹配任意不是空白符的字符',
}, {
code: '\\D',
explanation: '匹配任意非数字的字符',
}, {
code: '\\B',
explanation: '匹配不是单词开头或结束的位置',
},
{
code: '[^x]',
explanation: '匹配除了x以外的任意字符',
},
{
code: '[^aeiou]',
explanation: '匹配除了aeiou这几个字母以外的任意字符',
},
],
}
},
methods: {
print(data) {
this.input = data
},
}
}
</script>
<style scoped>
</style>

@ -42,4 +42,14 @@ public class RegexConst {
* url * url
*/ */
public static final String URL_REGEX= "(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"; public static final String URL_REGEX= "(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]";
/**
* 16md5
*/
public static final String MD5_16_REGEX= "([a-f\\d]{32}|[A-F\\d]{32})";
/**
* 32md5
*/
public static final String MD5_32_REGEX= "([a-f\\d]{16}|[A-F\\d]{16})";
} }

@ -84,6 +84,7 @@ public class ApiLogController extends BaseController {
@PostMapping("/export") @PostMapping("/export")
@ApiOperation("导出日志列表") @ApiOperation("导出日志列表")
public void export(HttpServletResponse response, ApiLog apiLog) { public void export(HttpServletResponse response, ApiLog apiLog) {
startPage();
List<ApiLog> list = apiLogService.selectApiLogList(apiLog); List<ApiLog> list = apiLogService.selectApiLogList(apiLog);
ExcelUtil<ApiLog> util = new ExcelUtil<ApiLog>(ApiLog.class); ExcelUtil<ApiLog> util = new ExcelUtil<ApiLog>(ApiLog.class);
util.exportExcel(response, list, "日志数据"); util.exportExcel(response, list, "日志数据");

@ -0,0 +1,73 @@
package com.xjs.tools;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.security.annotation.RequiresLogin;
import com.xjs.exception.BusinessException;
import com.xjs.tools.domain.ToolMd5;
import com.xjs.tools.service.ToolMd5Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.regex.Pattern;
import static com.xjs.consts.RegexConst.*;
/**
* md5Controller
*
* @author xiejs
* @since 2022-05-10
*/
@RestController
@RequestMapping("md5")
@Api(tags = "业务模块-md5加解密")
@Log4j2
@Validated
public class ToolMd5Controller {
@Autowired
private ToolMd5Service toolMd5Service;
@GetMapping("encryption")
@ApiOperation("加密md5")
@Log(title = "加密md5")
@RequiresLogin
public AjaxResult encryption(@NotBlank(message = "参数不能为空") @Size(max = 20, message = "长度不能大于 20 字符") String str) {
ToolMd5 md5 = toolMd5Service.encryption(str);
return AjaxResult.success(md5);
}
@GetMapping("decrypt")
@ApiOperation("解密md5")
@Log(title = "解密md5")
@RequiresLogin
public AjaxResult decrypt(@NotBlank(message = "参数不能为空") @Size(max = 32, message = "长度不能大于 32 字符") String str) {
boolean md516Regex = Pattern.matches(MD5_16_REGEX, str);
boolean md532Regex = Pattern.matches(MD5_32_REGEX, str);
if (!md516Regex && !md532Regex) {
throw new BusinessException("请输入正确的md5");
}
String value = toolMd5Service.decrypt(str);
if (StringUtils.isEmpty(value)) {
throw new BusinessException("解密未成功");
}
return AjaxResult.success(value);
}
}

@ -0,0 +1,50 @@
package com.xjs.tools.domain;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.core.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* md5
*
* @author xiejs
* @since 2022-05-10
*/
@Data
public class ToolMd5 implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long id;
/**
*
*/
@Excel(name = "来源字符")
private String source;
/**
* 16
*/
@Excel(name = "目标字符16位")
private String target16;
/**
* 32
*/
@Excel(name = "目标字符32位")
private String target32;
@Excel(name = "创建时间",dateFormat = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
}

@ -0,0 +1,14 @@
package com.xjs.tools.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjs.tools.domain.ToolMd5;
/**
* md5mapper
*
* @author xiejs
* @since 2022-05-10
*/
public interface ToolMd5Mapper extends BaseMapper<ToolMd5> {
}

@ -0,0 +1,26 @@
package com.xjs.tools.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.tools.domain.ToolMd5;
/**
* md5service
* @author xiejs
* @since 2022-05-10
*/
public interface ToolMd5Service extends IService<ToolMd5> {
/**
* md5
* @param str
* @return 1632md5
*/
ToolMd5 encryption(String str);
/**
* md5
* @param str md5
* @return
*/
String decrypt(String str);
}

@ -0,0 +1,64 @@
package com.xjs.tools.service.impl;
import cn.hutool.crypto.digest.DigestUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.tools.domain.ToolMd5;
import com.xjs.tools.mapper.ToolMd5Mapper;
import com.xjs.tools.service.ToolMd5Service;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* md5service
* @author xiejs
* @since 2022-05-10
*/
@Service
public class ToolMd5ServiceImpl extends ServiceImpl<ToolMd5Mapper, ToolMd5> implements ToolMd5Service {
@Override
public ToolMd5 encryption(String str) {
String md5Hex32 = DigestUtil.md5Hex(str);
String md5Hex16 = DigestUtil.md5Hex16(str);
ToolMd5 toolMd5 = new ToolMd5();
toolMd5.setSource(str);
toolMd5.setTarget16(md5Hex16);
toolMd5.setTarget32(md5Hex32);
try {
LambdaQueryWrapper<ToolMd5> wrapper = new LambdaQueryWrapper<ToolMd5>()
.eq(ToolMd5::getTarget16, toolMd5.getTarget16())
.eq(ToolMd5::getTarget32, toolMd5.getTarget32());
ToolMd5 one = super.getOne(wrapper, false);
if (Objects.isNull(one)) {
super.save(toolMd5);
}
} catch (Exception e) {
e.printStackTrace();
}
return toolMd5;
}
@Override
public String decrypt(String str) {
str = str.toLowerCase();
LambdaQueryWrapper<ToolMd5> wrapper = new LambdaQueryWrapper<ToolMd5>()
.eq(ToolMd5::getTarget32, str)
.or()
.eq(ToolMd5::getTarget16, str);
ToolMd5 one = super.getOne(wrapper, false);
if (one != null) {
return one.getSource();
}
return "";
}
}

@ -0,0 +1,75 @@
package com.xjs.domain.todo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.core.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* todo_list
*
* @author xiejs
* @since 2022-05-07
*/
@Data
public class TodoList implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long id;
/**
*
*/
@Excel(name = "待办内容")
private String content;
/**
* #999999
*/
@Excel(name = "颜色 #999999")
private String color;
/**
*
*/
@Excel(name = "排序")
private Long sort;
/**
*
*/
@Excel(name = "截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/**
* 1: 2:
*/
@Excel(name = "是否完成", readConverterExp = " 1=完成,2=未完成")
private Integer success;
/**
* id
*/
@Excel(name = "待办类别id")
private Long categoryId;
/**
*
*/
@Excel(name = "创建者")
private String createBy;
/**
*
*/
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
}
Loading…
Cancel
Save