fix: captcha aes encrypt

pull/209/head
xingyu4j 2025-09-03 18:04:35 +08:00
parent 1b4335760b
commit 7f3e2a90ae
2 changed files with 6 additions and 5 deletions

View File

@ -21,9 +21,9 @@ export const AES = {
if (!key) {
throw new Error('AES 加密密钥不能为空');
}
if (key.length !== 32) {
if (key.length !== 32 && key.length !== 16) {
throw new Error(
`AES 加密密钥长度必须为 32 位,当前长度: ${key.length}`,
`AES 加密密钥长度必须为 32 位或 16 位,当前长度: ${key.length}`,
);
}

View File

@ -17,7 +17,8 @@ import {
import { $t } from '@vben/locales';
import { aesEncrypt } from './utils/ase';
import { AES } from '@vben-core/shared/utils';
import { resetSize } from './utils/util';
const props = withDefaults(defineProps<VerificationProps>(), {
@ -179,7 +180,7 @@ function end() {
const data = {
captchaType: captchaType.value,
pointJson: secretKey.value
? aesEncrypt(
? AES.encrypt(
JSON.stringify({ x: moveLeftDistance, y: 5 }),
secretKey.value,
)
@ -205,7 +206,7 @@ function end() {
tipWords.value = `${((endMovetime.value - startMoveTime.value) / 1000).toFixed(2)}s
${$t('ui.captcha.title')}`;
const captchaVerification = secretKey.value
? aesEncrypt(
? AES.encrypt(
`${backToken.value}---${JSON.stringify({ x: moveLeftDistance, y: 5 })}`,
secretKey.value,
)