UNPKG

modi-cli

Version:

Console application for provisioning, displaying or destroying virtual machines in MODI

48 lines (36 loc) 1.67 kB
var definitions = require('./Define.js'); var crypto = require('crypto'); //var encryptionKey = definitions.encryptionKey; var encryptionKey; var osversion = process.platform; if (process.env["MODICLILOGINTOKEN"] != undefined) encryptionKey = process.env["MODICLILOGINTOKEN"]; else { switch (osversion) { case 'win32': console.log('Please close all the command prompt windows and re-run the "modi" command. If you see this message again, please reinstall the modi-cli application due to missing registry keys'); break; case 'linux': case 'darwin': console.log('Please execute shell command "source ~/.bash_profile" and re-launch the application. If you see this message again, you will have to reinstall the modi-cli application due to missing registry keys'); break; default : console.log('Please reinstall the modi-cli application due to missing registry keys'); } process.exit(0); } var encryptionAlgorithm = definitions.encryptionAlgorithm; function Encrypt(data) { var cipher = crypto.createCipher(encryptionAlgorithm, encryptionKey); var encryptedData = cipher.update(data, 'utf8', 'base64'); encryptedData += cipher.final('base64'); return encryptedData; } function Decrypt(data) { var decipher = crypto.createDecipher(encryptionAlgorithm, encryptionKey); var decryptedData = decipher.update(data, 'base64', 'utf8'); decryptedData += decipher.final('utf8'); return decryptedData; } exports.Encrypt = Encrypt; exports.Decrypt = Decrypt;