encrypt phone number

This commit is contained in:
hyunwoo93.cha
2024-07-23 18:49:11 +09:00
parent 573cd1a2d7
commit dab0ca17ff
2 changed files with 47 additions and 44 deletions

View File

@@ -1,63 +1,47 @@
import React, {
useCallback,
useEffect,
useMemo,
useState,
} from 'react';
import React, { useCallback, useEffect, useMemo, useState } from "react";
import classNames from 'classnames';
import classNames from "classnames";
import CryptoJS from "crypto-js";
import {
AsYouTypeFormatter,
PhoneNumberFormat,
PhoneNumberUtil,
} from 'google-libphonenumber';
import {
useDispatch,
useSelector,
} from 'react-redux';
} from "google-libphonenumber";
import { useDispatch, useSelector } from "react-redux";
import {
off,
on,
} from '@enact/core/dispatcher';
import spotlight, { Spotlight } from '@enact/spotlight';
import {
SpotlightContainerDecorator,
} from '@enact/spotlight/SpotlightContainerDecorator';
import { Spottable } from '@enact/spotlight/Spottable';
import { off, on } from "@enact/core/dispatcher";
import spotlight, { Spotlight } from "@enact/spotlight";
import { SpotlightContainerDecorator } from "@enact/spotlight/SpotlightContainerDecorator";
import { Spottable } from "@enact/spotlight/Spottable";
import defaultImage from '../../../assets/images/img-thumb-empty-144@3x.png';
import { types } from '../../actions/actionTypes';
import {
clearSMS,
sendSms,
} from '../../actions/appDataActions';
import defaultImage from "../../../assets/images/img-thumb-empty-144@3x.png";
import { types } from "../../actions/actionTypes";
import { clearSMS, sendSms } from "../../actions/appDataActions";
import {
changeLocalSettings,
setHidePopup,
setShowPopup,
} from '../../actions/commonActions';
} from "../../actions/commonActions";
import {
clearRegisterDeviceInfo,
getDeviceAdditionInfo,
registerDeviceInfo,
} from '../../actions/deviceActions';
} from "../../actions/deviceActions";
import {
clearCurationCoupon,
setEventIssueReq,
} from '../../actions/eventActions';
import { sendLogShopByMobile } from '../../actions/logActions';
import {
ACTIVE_POPUP,
LOG_TP_NO,
} from '../../utils/Config';
import { $L } from '../../utils/helperMethods';
import CustomImage from '../CustomImage/CustomImage';
import TButton from '../TButton/TButton';
import TPopUp from '../TPopUp/TPopUp';
import HistoryPhoneNumber from './HistoryPhoneNumber/HistoryPhoneNumber';
import css from './MobileSendPopUp.module.less';
import SMSNumKeyPad from './SMSNumKeyPad';
} from "../../actions/eventActions";
import { sendLogShopByMobile } from "../../actions/logActions";
import { ACTIVE_POPUP, LOG_TP_NO } from "../../utils/Config";
import { $L } from "../../utils/helperMethods";
import CustomImage from "../CustomImage/CustomImage";
import TButton from "../TButton/TButton";
import TPopUp from "../TPopUp/TPopUp";
import HistoryPhoneNumber from "./HistoryPhoneNumber/HistoryPhoneNumber";
import css from "./MobileSendPopUp.module.less";
import SMSNumKeyPad from "./SMSNumKeyPad";
const SECRET_KEY = "fy7BTKuM9eeTQqEC9sF3Iw5qG43Aaip";
const Container = SpotlightContainerDecorator(
{ enterTo: "last-focused" },
@@ -299,6 +283,10 @@ export default function MobileSendPopUp({
naturalNumber = "82" + naturalNumber;
}
const encryptPhoneNumber = (phoneNumber) => {
return CryptoJS.AES.encrypt(phoneNumber, SECRET_KEY).toString();
};
if (recentSentNumber && recentSentNumber.length > 0) {
const updatedNumbers = [...recentSentNumber];
@@ -317,10 +305,12 @@ export default function MobileSendPopUp({
setChkAgreeBtn(true);
setRecentSentNumber(updatedNumbers);
const encryptedNumbers = updatedNumbers.map(encryptPhoneNumber);
dispatch(
changeLocalSettings({
phoneNumbers: {
phoneNumberList: updatedNumbers,
phoneNumberList: encryptedNumbers,
},
})
);
@@ -329,7 +319,7 @@ export default function MobileSendPopUp({
dispatch(
changeLocalSettings({
phoneNumbers: {
phoneNumberList: [mobileNumber],
phoneNumberList: [encryptPhoneNumber(mobileNumber)],
},
})
);
@@ -526,6 +516,18 @@ export default function MobileSendPopUp({
(smsRetCode !== undefined && smsRetCode !== 0) ||
(curationCouponSuccess !== undefined && curationCouponSuccess !== 0);
useEffect(() => {
if (phoneNumberList) {
const decryptPhoneNumber = (encryptedPhoneNumber) => {
const bytes = CryptoJS.AES.decrypt(encryptedPhoneNumber, SECRET_KEY);
return bytes.toString(CryptoJS.enc.Utf8);
};
const decryptedNumbers = phoneNumberList.map(decryptPhoneNumber);
setRecentSentNumber(decryptedNumbers);
}
}, []);
return (
<>
{smsRetCode === undefined &&