import Vue from "vue";
import { strEnc, strDec } from "./des";

var Aes = require("./aes");

var RSAKey = require("./rsa");

var rsa = {};

var DataProcess = function DataProcess() {
  rsa = new RSAKey();
};

DataProcess.desDecrypt = function (data, firstKey, secondKey, thirdKey) {
  return strDec(data, firstKey, secondKey, thirdKey);
};

DataProcess.desEncrypt = function (data, firstKey, secondKey, thirdKey) {
  return strEnc(data, firstKey, secondKey, thirdKey);
};

DataProcess.aesDecrypt = function (data, privateKey, nBits) {
  if (nBits === void 0) {
    nBits = 128;
  }

  return Aes.Ctr.decrypt(data, privateKey, nBits);
};

DataProcess.aesEncrypt = function (data, privateKey, nBits) {
  if (nBits === void 0) {
    nBits = 128;
  }

  return Aes.Ctr.encrypt(data, privateKey, nBits);
};

DataProcess.setPublic = function (N, E) {
  rsa.setPublic(N, E);
};

DataProcess.rsaEncrypt = function (data) {
  return rsa.encrypt(data);
};

DataProcess.setPrivate = function (N, E, D) {
  rsa.setPrivate(N, E, D);
};

DataProcess.rsaDecrypt = function (data) {
  return rsa.decrypt(data);
};

Vue.prototype.$DataProcess = DataProcess;
export default DataProcess;