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) { if (!key) {
throw new Error('AES 加密密钥不能为空'); throw new Error('AES 加密密钥不能为空');
} }
if (key.length !== 32) { if (key.length !== 32 && key.length !== 16) {
throw new Error( 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 { $t } from '@vben/locales';
import { aesEncrypt } from './utils/ase'; import { AES } from '@vben-core/shared/utils';
import { resetSize } from './utils/util'; import { resetSize } from './utils/util';
const props = withDefaults(defineProps<VerificationProps>(), { const props = withDefaults(defineProps<VerificationProps>(), {
@ -179,7 +180,7 @@ function end() {
const data = { const data = {
captchaType: captchaType.value, captchaType: captchaType.value,
pointJson: secretKey.value pointJson: secretKey.value
? aesEncrypt( ? AES.encrypt(
JSON.stringify({ x: moveLeftDistance, y: 5 }), JSON.stringify({ x: moveLeftDistance, y: 5 }),
secretKey.value, secretKey.value,
) )
@ -205,7 +206,7 @@ function end() {
tipWords.value = `${((endMovetime.value - startMoveTime.value) / 1000).toFixed(2)}s tipWords.value = `${((endMovetime.value - startMoveTime.value) / 1000).toFixed(2)}s
${$t('ui.captcha.title')}`; ${$t('ui.captcha.title')}`;
const captchaVerification = secretKey.value const captchaVerification = secretKey.value
? aesEncrypt( ? AES.encrypt(
`${backToken.value}---${JSON.stringify({ x: moveLeftDistance, y: 5 })}`, `${backToken.value}---${JSON.stringify({ x: moveLeftDistance, y: 5 })}`,
secretKey.value, secretKey.value,
) )