// 引用AES源码js
const CryptoJS = require('crypto-js')

function Encrypt(word) {
  var key = CryptoJS.enc.Utf8.parse('authentication')

  var srcs = CryptoJS.enc.Utf8.parse(word)
  var encrypted = CryptoJS.DES.encrypt(srcs, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7})
  return encrypted.toString()
}

function Decrypt(word) {
  var key = CryptoJS.enc.Utf8.parse('authentication')

  var decrypt = CryptoJS.DES.decrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7})
  return CryptoJS.enc.Utf8.stringify(decrypt).toString()
}

export {
  Encrypt,
  Decrypt
}
