"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _cryptoJs = _interopRequireDefault(require("crypto-js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
// 这里是密钥
var keyHex = 'NT9FWl3ze1GJNqpo';
var ivHex = 'vL7iWTTV7RngvKkn';

// 解密  data：要加密解密的数据，AES_KEY：密钥，IV:偏移量
var encrypt = function encrypt(data, options) {
  var _ref = options && _typeof(options) === 'object' ? options : {},
    AES_KEY = _ref.key,
    IV = _ref.iv,
    mode = _ref.mode;
  var key = _cryptoJs["default"].enc.Utf8.parse(AES_KEY || keyHex);
  var iv = _cryptoJs["default"].enc.Utf8.parse(IV || ivHex);
  return _cryptoJs["default"].AES.encrypt(data, key, {
    iv: iv,
    mode: _cryptoJs["default"].mode[mode || 'CBC'],
    padding: _cryptoJs["default"].pad.Pkcs7
  }).toString();
};
var encryptParams = function encryptParams(params, options) {
  var _params;
  if ((_params = params) !== null && _params !== void 0 && _params.cql_filter) {
    params = JSON.parse(JSON.stringify(params));
    params.CQL_FILTER_ENCRYPT = encrypt(encodeURI(params.cql_filter), options);
    delete params.cql_filter;
  }
  return params;
};
var _default = exports["default"] = encryptParams;
//# sourceMappingURL=encryptParams.js.map
