forked from GitHub/dbot
Moved crypto module to internal node crypto api, removed (pretty) senseless cipher command and added random command
This commit is contained in:
parent
15de4c4f5d
commit
79dd53e4c4
2
install
2
install
@ -14,7 +14,7 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
npm install googlemaps feedparser node-units tvdb crypto-js method-override 500px process async wordnik node-uuid underscore request sandbox express moment-timezone moment jade databank databank-redis ent passport passport-local password-hash connect-flash
|
npm install googlemaps feedparser node-units tvdb method-override 500px process async wordnik node-uuid underscore request sandbox express moment-timezone moment jade databank databank-redis ent passport passport-local password-hash connect-flash
|
||||||
|
|
||||||
cd public/
|
cd public/
|
||||||
wget https://github.com/twbs/bootstrap/releases/download/v3.3.2/bootstrap-3.3.2-dist.zip
|
wget https://github.com/twbs/bootstrap/releases/download/v3.3.2/bootstrap-3.3.2-dist.zip
|
||||||
|
@ -7,15 +7,9 @@ This module calculates different hashes or ciphertexts for some algorithms.
|
|||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
#### ~md5 [text]
|
#### ~hash [algorithm] [text]
|
||||||
Calculate the MD5 hash of the given text.
|
Calculate the hash of the given text using [algorithm].
|
||||||
|
|
||||||
#### ~sha1 [text]
|
#### ~random [number]
|
||||||
Calculate the SHA1 hash of the given text.
|
Gives [number] bytes of cryptographically strong pseudo-random data as hex string.
|
||||||
|
|
||||||
#### ~sha256 [text]
|
|
||||||
Calculate the SHA256 hash of the given text.
|
|
||||||
|
|
||||||
#### ~aes "[text]" "[key]"
|
|
||||||
Calculates the hash of the given text.
|
|
||||||
|
|
||||||
|
@ -3,32 +3,40 @@
|
|||||||
* Description: Allows the magic of cryptography to take place.
|
* Description: Allows the magic of cryptography to take place.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var MD5 = require('crypto-js/md5');
|
var cr = require('crypto');
|
||||||
var SHA1 = require('crypto-js/sha1');
|
|
||||||
var SHA256 = require('crypto-js/sha256');
|
|
||||||
var SHA512 = require('crypto-js/sha512');
|
|
||||||
var AES = require('crypto-js/aes');
|
|
||||||
|
|
||||||
var crypto = function(dbot) {
|
var crypto = function(dbot) {
|
||||||
this.commands = {
|
this.commands = {
|
||||||
'~md5': function(event) {
|
'~hash': function(event) {
|
||||||
event.reply("MD5 hash of "+event.input[1]+" is: "+MD5(event.input[1]));
|
var hash = event.params[1];
|
||||||
|
try {
|
||||||
|
var h = cr.createHash(hash);
|
||||||
|
var tohash = event.params.splice(2, event.params.length-1).join(' ');
|
||||||
|
h.update(tohash);
|
||||||
|
event.reply(hash+" of \""+tohash+"\" is: "+h.digest('hex'));
|
||||||
|
} catch(err) {
|
||||||
|
event.reply(err);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'~sha1': function(event) {
|
'~random': function(event) {
|
||||||
event.reply("SHA1 hash of "+event.input[1]+" is: "+SHA1(event.input[1]));
|
try {
|
||||||
},
|
var count = parseInt(event.params[1]);
|
||||||
'~sha256': function(event) {
|
if(count > 222) {
|
||||||
event.reply("SHA256 hash of "+event.input[1]+" is: "+SHA256(event.input[1]));
|
event.reply("Sorry man, I can't paste that much random data.");
|
||||||
},
|
return;
|
||||||
'~aes': function(event) {
|
}
|
||||||
event.reply("AES of "+event.input[1]+" is: "+AES.encrypt(event.input[1],event.input[2]));
|
cr.randomBytes(count, function(err,buf) {
|
||||||
|
if(err) {
|
||||||
|
event.reply(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.reply(buf.toString('hex'));
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
event.reply(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.commands['~md5'].regex = /^md5 ([^ ]+)$/;
|
|
||||||
this.commands['~sha1'].regex = /^sha1 ([^ ]+)$/;
|
|
||||||
this.commands['~sha256'].regex = /^sha256 ([^ ]+)$/;
|
|
||||||
this.commands['~aes'].regex = /^aes "(.*)" "(.*)"$/;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.fetch = function(dbot) {
|
exports.fetch = function(dbot) {
|
||||||
|
Loading…
Reference in New Issue
Block a user