import { encrypt, decrypt } from "crypto-js/aes"
import { parse } from "crypto-js/enc-utf8"
import pkcs7 from "crypto-js/pad-pkcs7"
import ECB from "crypto-js/mode-ecb"
import UTF8 from "crypto-js/enc-utf8"
// 注意 key 和 iv 至少都需要 16 位
const AES_KEY = "1111111111000000"
const AES_IV = "0000001111111111"

/**
 *
 * @description 加密:反序列化字符串参数
 */

export function stringifyQuery(query: string) {
  return `?${encrypt(query, parse(AES_KEY), {
    mode: ECB,
    padding: pkcs7,
    iv: parse(AES_IV)
  }).toString()}`
}
