Sorry, this is not a code question.
I'm currently working on a web application using React.
I've been using Redux to manage user registration information (ex: email address, etc.) for user registration over several pages, but I noticed that the registered information disappears after reloading.
I thought about saving the information to localStorage, but gave up due to the security risk.
How would you guys keep your users' registration information?
If the information is not much, you could use encrypted cookie data, and read back the data on page load.
.env file in your project root folderREACT_APP_PASS=8604460484466 const encryptWithAES = (text, pass) => {
const passphrase = pass;
return CryptoJS.AES.encrypt(text, passphrase).toString();
}; // remember to import CryptoJS
export const decryptWithAES = (ciphertext, pass) => {
const passphrase = pass;
const bytes = CryptoJS.AES.decrypt(ciphertext, passphrase);
const originalText = bytes.toString(CryptoJS.enc.Utf8);
return originalText;
};
const tobeStored = encryptWithAES('text to encrypt', process.env.REACT_APP_PASS);
// then store it in your cookie.
const cookieData = someGetCookieFunction('UserInfo');
const decrypted = decryptWithAES(cookieData,process.env.REACT_APP_PASS);
See more information here and Here As well on how to set and call environment variables.