outers
Version:
outers - a all in one package for your day to day use
91 lines • 4.96 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Encryption_Key;
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-explicit-any */
// Import Encrypt and Decrypt
const Encrypt_1 = require("./functions/Encrypt"); // Import Encrypt Module
const Decrypt_1 = require("./functions/Decrypt"); // Import Decrypt Module
// Node Encryption Class
class Encryption {
constructor(Key) {
_Encryption_Key.set(this, void 0); // The #Key property is a private property that can only be accessed within the class.
__classPrivateFieldSet(this, _Encryption_Key, Key, "f"); // Set Key to the key passed in the constructor
}
/**
* The function Decrypt takes a string of data and decrypts it using a specified key.
* @param {string} Data - The "Data" parameter is a string that represents the data that needs to be
* decrypted.
* @returns The decryptedData is being returned.
*/
Decrypt(Data) {
return __awaiter(this, void 0, void 0, function* () {
// Encrypt data
const decryptedData = yield (0, Decrypt_1.Decrypt)(Data, __classPrivateFieldGet(this, _Encryption_Key, "f"));
return decryptedData;
});
}
/**
* The function takes in data, converts it to a string, encrypts it using a key, and returns the
* encrypted data as a string.
* @param {any} Data - The "Data" parameter is of type "any", which means it can accept any data type.
* It is the data that you want to encrypt.
* @returns a promise that resolves to a string.
*/
Encrypt(Data) {
return __awaiter(this, void 0, void 0, function* () {
// Convert data to string
const ReadyData = JSON.stringify(Data);
// Encrypt data
const encryptedData = yield (0, Encrypt_1.Encrypt)(ReadyData, __classPrivateFieldGet(this, _Encryption_Key, "f"));
return encryptedData;
});
}
/**
* The function DecryptSync takes a string of data and decrypts it using a specified key.
* @param {string} Data - The "Data" parameter is a string that represents the data that needs to be
* decrypted.
* @returns The decrypted data is being returned.
*/
DecryptSync(Data) {
// Encrypt data
const decryptedData = (0, Decrypt_1.DecryptSync)(Data, __classPrivateFieldGet(this, _Encryption_Key, "f"));
return decryptedData;
}
/**
* The function takes in data, converts it to a string, encrypts it using a specified key, and returns
* the encrypted data as a string.
* @param {any} Data - The "Data" parameter is of type "any", which means it can accept any data type.
* It is the data that you want to encrypt.
* @returns the encrypted data as a string.
*/
EncryptSync(Data) {
// Convert data to string
const ReadyData = JSON.stringify(Data);
// Encrypt data
const encryptedData = (0, Encrypt_1.EncryptSync)(ReadyData, __classPrivateFieldGet(this, _Encryption_Key, "f"));
return encryptedData;
}
}
_Encryption_Key = new WeakMap();
exports.default = Encryption;
//# sourceMappingURL=Dispatcher.js.map