crypto
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
|
||||
import classNames from "classnames";
|
||||
import CryptoJS from "crypto-js";
|
||||
import {
|
||||
AsYouTypeFormatter,
|
||||
PhoneNumberFormat,
|
||||
@@ -284,7 +283,10 @@ export default function MobileSendPopUp({
|
||||
}
|
||||
|
||||
const encryptPhoneNumber = (phoneNumber) => {
|
||||
return CryptoJS.AES.encrypt(phoneNumber, SECRET_KEY).toString();
|
||||
if(typeof window === 'object'){
|
||||
return window.CryptoJS.AES.encrypt(phoneNumber, SECRET_KEY).toString();
|
||||
}
|
||||
return phoneNumber;
|
||||
};
|
||||
|
||||
if (recentSentNumber && recentSentNumber.length > 0) {
|
||||
@@ -519,8 +521,11 @@ export default function MobileSendPopUp({
|
||||
useEffect(() => {
|
||||
if (phoneNumberList) {
|
||||
const decryptPhoneNumber = (encryptedPhoneNumber) => {
|
||||
const bytes = CryptoJS.AES.decrypt(encryptedPhoneNumber, SECRET_KEY);
|
||||
return bytes.toString(CryptoJS.enc.Utf8);
|
||||
if(typeof window === 'object'){
|
||||
const bytes = window.CryptoJS.AES.decrypt(encryptedPhoneNumber, SECRET_KEY);
|
||||
return bytes.toString(window.CryptoJS.enc.Utf8);
|
||||
}
|
||||
return encryptedPhoneNumber;
|
||||
};
|
||||
|
||||
const decryptedNumbers = phoneNumberList.map(decryptPhoneNumber);
|
||||
|
||||
Reference in New Issue
Block a user