3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 21:09:31 +01:00
dbot/modules/crypto/crypto.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-12-26 07:44:13 +01:00
/**
2013-12-26 07:59:56 +01:00
* Module Name: Crypto
* Description: Allows the magic of cryptography to take place.
2013-12-26 07:44:13 +01:00
*/
var MD5 = require('crypto-js/md5');
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) {
this.commands = {
'~md5': function(event) {
event.reply("MD5 hash of "+event.input[1]+" is: "+MD5(event.input[1]));
},
'~sha1': function(event) {
event.reply("SHA1 hash of "+event.input[1]+" is: "+SHA1(event.input[1]));
},
'~sha256': function(event) {
event.reply("SHA256 hash of "+event.input[1]+" is: "+SHA256(event.input[1]));
},
'~aes': function(event) {
event.reply("AES of "+event.input[1]+" is: "+AES.encrypt(event.input[1],event.input[2]));
}
};
2013-12-29 19:38:24 +01:00
this.commands['~md5'].regex = /^md5 ([^ ]+)$/;
this.commands['~sha1'].regex = /^sha1 ([^ ]+)$/;
this.commands['~sha256'].regex = /^sha256 ([^ ]+)$/;
this.commands['~aes'].regex = /^aes "(.*)" "(.*)"$/;
2013-12-26 07:44:13 +01:00
};
exports.fetch = function(dbot) {
return new crypto(dbot);
};