18 lines
No EOL
461 B
JavaScript
18 lines
No EOL
461 B
JavaScript
import CryptoJS from 'crypto-js';
|
|
|
|
const encryptWithAES = (text) => {
|
|
const passphrase = '123';
|
|
return CryptoJS.AES.encrypt(text, passphrase).toString();
|
|
};
|
|
|
|
const decryptWithAES = (ciphertext) => {
|
|
const passphrase = '123';
|
|
const bytes = CryptoJS.AES.decrypt(ciphertext, passphrase);
|
|
const originalText = bytes.toString(CryptoJS.enc.Utf8);
|
|
return originalText;
|
|
};
|
|
|
|
export {
|
|
encryptWithAES as encrypt,
|
|
decryptWithAES as decrypt
|
|
} |