"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _crypto = _interopRequireDefault(require("crypto"));

var _lodash = _interopRequireDefault(require("lodash"));

var index = /*#__PURE__*/function () {
  function index(Options) {
    (0, _classCallCheck2["default"])(this, index);
    this.Options = _lodash["default"].extend({
      iv: _crypto["default"].randomBytes(16),
      algorithm: 'aes-128-cbc',
      secretKey: "Cyberhack2010ue73ue@fjcncmejfhdw",
      keyLength: 24
    }, Options);
  }

  (0, _createClass2["default"])(index, [{
    key: "encode",
    value: function encode(text) {
      var mChiper = _crypto["default"].createCipher(this.Options.algorithm, this.Options.secretKey);

      var encrypted = mChiper.update(text, 'utf8', 'hex'); // Using concatenation

      encrypted += mChiper["final"]("hex");
      return encrypted;
    }
  }, {
    key: "decode",
    value: function decode(text) {
      var decipher = _crypto["default"].createDecipher(this.Options.algorithm, this.Options.secretKey);

      var decrypted = decipher.update(text, 'hex', 'utf8');
      decrypted += decipher["final"]("utf8");
      return decrypted;
    }
  }]);
  return index;
}();

var _default = index;
exports["default"] = _default;
//# sourceMappingURL=index.js.map