updated_at: 2024-12-15 04:07

CryptoJs

npm install --save crypto-js npm i --save-dev @types/crypto-js

encrypt

` import * as CryptoJS from 'crypto-js';

const secretKey = 'myScretKeyDontUsethisonPublic'; const data = { username: 'Pondol', age: 105 };

const encrypted = CryptoJS.AES.encrypt(JSON.stringify(data), secretKey).toString()

const encodedUrl = encodeURIComponent(encrypted); `

decrypt

` import * as CryptoJS from 'crypto-js';

const secretKey = 'myScretKeyDontUsethisonPublic';

const decodedUrl = decodeURIComponent(encodedUrl); const decrypted = CryptoJS.AES.decrypt(url, secretKey); const originalData = JSON.parse(decrypted.toString(CryptoJS.enc.Utf8)); `

Table of contents 목차

평점을 남겨주세요
평점 : 2.5
총 투표수 : 1

질문 및 답글