Browse Source

added experimental encrypt/decrypt key shepherd api

all-modes
Petr Balashov 8 years ago
parent
commit
fa93dc1e0a
  1. 41
      routes/shepherd.js

41
routes/shepherd.js

@ -17,6 +17,7 @@ const electron = require('electron'),
async = require('async'),
rimraf = require('rimraf'),
portscanner = require('portscanner'),
aes256 = require('nodejs-aes256'),
Promise = require('bluebird');
const fixPath = require('fix-path');
@ -137,6 +138,46 @@ shepherd.createIguanaDirs = function() {
}
}
shepherd.get('/encryptkey', function(req, res, next) {
if (req.query.ckey &&
req.query.string) {
const encryptedKey = aes256.encrypt(req.query.ckey, req.query.string);
const successObj = {
'msg': 'success',
'result': encryptedKey
};
res.end(JSON.stringify(successObj));
} else {
const errorObj = {
'msg': 'error',
'result': 'missing ckey or string to encrypt param'
};
res.end(JSON.stringify(errorObj));
}
});
shepherd.get('/decryptkey', function(req, res, next) {
if (req.query.ckey &&
req.query.string) {
const encryptedKey = aes256.decrypt(req.query.ckey, req.query.string);
const successObj = {
'msg': 'success',
'result': encryptedKey
};
res.end(JSON.stringify(successObj));
} else {
const errorObj = {
'msg': 'error',
'result': 'missing ckey or string to encrypt param'
};
res.end(JSON.stringify(errorObj));
}
});
shepherd.get('/coinslist', function(req, res, next) {
if (fs.existsSync(iguanaDir + '/shepherd/coinslist.json')) {
fs.readFile(iguanaDir + '/shepherd/coinslist.json', 'utf8', function (err, data) {

Loading…
Cancel
Save