UNPKG

open-api-aurum-connector2

Version:

Module to connect to the OPEN API Aurum Core

23 lines (18 loc) 911 B
const { module_name, configurations_key } = require("../utils/Constants.js"); const { logger } = require("../utils/Logger.js"); const CryptoJS = require("crypto-js"); const cryptPass = (plaintextPassword) => { logger.info(`module-hub-aurum-core-connector :: cryptoAESauth "${module_name}" ...`); const config = global[configurations_key]; const CONSUMER_KEY = config?.consumerKey || ""; logger.info(`module-hub-aurum-core-connector :: CONSUMER_KEY: ${CONSUMER_KEY}`); let preEncypted = CryptoJS.SHA1(CryptoJS.enc.Utf8.parse(CONSUMER_KEY)); let newKey = CryptoJS.enc.Hex.parse(preEncypted.toString(CryptoJS.enc.Hex).substr(0, 32)); var encrypted = CryptoJS.AES.encrypt(plaintextPassword, newKey, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, }); logger.info(`module-hub-aurum-core-connector :: Encrypted: ${encrypted}`); return encrypted; }; module.exports = cryptPass;