feat: 新增行为验证码

This commit is contained in:
Yoofff
2024-05-17 07:29:59 +00:00
committed by Charles7c
parent 30222b08ab
commit 778b3c677f
10 changed files with 1316 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ import Base64 from 'crypto-js/enc-base64'
import UTF8 from 'crypto-js/enc-utf8'
import { JSEncrypt } from 'jsencrypt'
import md5 from 'crypto-js/md5'
import CryptoJS from 'crypto-js'
export function encodeByBase64(txt: string) {
return UTF8.parse(txt).toString(Base64)
@@ -24,3 +25,15 @@ export function encryptByRsa(txt: string) {
encryptor.setPublicKey(publicKey) // 设置公钥
return encryptor.encrypt(txt) // 对数据进行加密
}
const defaultKeyWork = 'XwKsGlMcdPMEhR1B'
export function aesEncrypt(word, keyWord = defaultKeyWork) {
const key = CryptoJS.enc.Utf8.parse(keyWord)
const arcs = CryptoJS.enc.Utf8.parse(word)
const encrypted = CryptoJS.AES.encrypt(arcs, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return encrypted.toString()
}

39
src/utils/verify.ts Normal file
View File

@@ -0,0 +1,39 @@
export function resetSize(vm) {
let img_width
let img_height
let bar_width
let bar_height // 图片的宽度、高度,移动条的宽度、高度
const parentWidth = vm.$el.parentNode.offsetWidth || window.innerWidth
const parentHeight = vm.$el.parentNode.offsetHeight || window.innerHeight
if (vm.imgSize.width.includes('%')) {
img_width = `${(Number.parseInt(vm.imgSize.width, 10) / 100) * parentWidth}px`
} else {
img_width = vm.imgSize.width
}
if (vm.imgSize.height.includes('%')) {
img_height = `${(Number.parseInt(vm.imgSize.height, 10) / 100) * parentHeight}px`
} else {
img_height = vm.imgSize.height
}
if (vm.barSize.width.includes('%')) {
bar_width = `${(Number.parseInt(vm.barSize.width, 10) / 100) * parentWidth}px`
} else {
bar_width = vm.barSize.width
}
if (vm.barSize.height.includes('%')) {
bar_height = `${(Number.parseInt(vm.barSize.height, 10) / 100) * parentHeight}px`
} else {
bar_height = vm.barSize.height
}
return {
imgWidth: img_width,
imgHeight: img_height,
barWidth: bar_width,
barHeight: bar_height
}
}