import CryptoJS from 'crypto-js';
export default {

	key : CryptoJS.enc.Utf8.parse("1234123412ABCDEF"),  //十六位十六进制数作为密钥
    iv :  CryptoJS.enc.Utf8.parse('8105548186756005'),   //十六位十六进制数作为密钥偏移量

	decode:function(word) {
		let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
		let decrypt = CryptoJS.AES.decrypt(CryptoJS.enc.Base64.stringify(encryptedHexStr), this.key, { iv: this.iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
		let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
		return decryptedStr.toString();
	},

	//加密方法
	encode:function(word) {
		let encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(word), this.key, { iv: this.iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
		return encrypted.ciphertext.toString().toUpperCase();
	}

}
