21 lines
601 B
JavaScript
21 lines
601 B
JavaScript
|
|
import CryptoJS from 'crypto-js'
|
||
|
|
|
||
|
|
const KEY = CryptoJS.enc.Utf8.parse('BDQH');
|
||
|
|
|
||
|
|
export const encrypt = (plaintext) => {
|
||
|
|
if(plaintext !== null && plaintext !== undefined && plaintext !== "") {
|
||
|
|
return CryptoJS.AES.encrypt(plaintext, KEY, {
|
||
|
|
mode: CryptoJS.mode.ECB,
|
||
|
|
padding: CryptoJS.pad.Pkcs7
|
||
|
|
}).toString();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export const decrypt = (plaintext) => {
|
||
|
|
if(plaintext !== null && plaintext !== undefined && !plaintext == "") {
|
||
|
|
return CryptoJS.AES.decrypt(plaintext, KEY, {
|
||
|
|
mode: CryptoJS.mode.ECB,
|
||
|
|
padding: CryptoJS.pad.Pkcs7
|
||
|
|
}).toString(CryptoJS.enc.Utf8);
|
||
|
|
}
|
||
|
|
}
|