import CryptoJS from 'crypto-js'
import moment from 'moment'
// 密钥
const secretKey = 'B447B88D5AF5A99A' + moment().format('YYYYMMDD');

//模拟参数
// const url = `username=wangjintao&plazaId=1000772&time=1611198103138&assead=1231231`
const url = `username=wangjintao&plazaId=1000772&time=1611198103138`

// 加密
export  function encrypted (){
    const encJson =CryptoJS.AES.encrypt(url,secretKey).toString();
    return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(encJson));
}
// 解密
export function decrypted (url) {
    const decData = CryptoJS.enc.Base64.parse(url).toString(CryptoJS.enc.Utf8)
    return CryptoJS.AES.decrypt(decData, secretKey).toString(CryptoJS.enc.Utf8);
}
// window.encrypted = encrypted