From 481521f9a75789c6df42e81d46118989d33bebb4 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期二, 08 八月 2023 16:36:31 +0800 Subject: [PATCH] Update: [顧問登入] AES 加密 with 參數(仍解密失敗) --- PAMapp/shared/services/login.service.ts | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/PAMapp/shared/services/login.service.ts b/PAMapp/shared/services/login.service.ts index 0c05281..7ee4a0b 100644 --- a/PAMapp/shared/services/login.service.ts +++ b/PAMapp/shared/services/login.service.ts @@ -9,6 +9,7 @@ import { LoginVerify } from "../models/loginVerify.model"; import { OtpInfo } from "../models/otpInfo.model"; import { RegisterInfo } from "../models/registerInfo"; +import CryptoJS from "crypto-js"; class LoginService { /** 憿批恥��-��TP **/ @@ -85,9 +86,17 @@ /** 憿批�� **/ logInToConsultant(consultantDto:ConsultantLoginInfo, verificationCode: string):Promise<AxiosResponse<LoginSuccessToken>>{ - const encryptPassword = AES.encrypt(consultantDto.password, 'PAM KEY').toString(); - return http.post(`/eService/authenticate/${verificationCode}`, { ...consultantDto, password: encryptPassword }); + const plaintext = consultantDto.password; + const key = "PAM KEY"; + const iv = "0123456789abcdef"; + const keyBytes = CryptoJS.enc.Utf8.parse(key); + const ivBytes = CryptoJS.enc.Utf8.parse(iv); + const encrypted = CryptoJS.AES.encrypt(plaintext, keyBytes, { iv: ivBytes, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); + + return http.post(`/eService/authenticate/${verificationCode}`, { ...consultantDto, password: encrypted.toString() }); } + + } export default new LoginService(); -- Gitblit v1.8.0