From 7a51fdf524544318c11cc6e7908adfe1302e6455 Mon Sep 17 00:00:00 2001 From: amki Date: Thu, 26 Dec 2013 06:44:13 +0000 Subject: [PATCH] Added crypto module --- modules/crypto/README.md | 29 +++++++++++++++++++++++++++++ modules/crypto/crypto.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 modules/crypto/README.md create mode 100644 modules/crypto/crypto.js diff --git a/modules/crypto/README.md b/modules/crypto/README.md new file mode 100644 index 0000000..aac11fc --- /dev/null +++ b/modules/crypto/README.md @@ -0,0 +1,29 @@ +## Reddit + +Various Reddit functionality + +### Description + +This module provides Reddit related functionality, which is currently limited to +reading various links, but will be expanded in future to include stuff like +monitoring posts and creating its own. + +### API + +#### getSubredditInfo(name, callback) +Get information about a subreddit from the Reddit API. Callback takes one +argument, the data returned from the API. + +#### getPostInfo(name, callback) +Get information about a post from the Reddit API. Callback takes one argument, +the data returned from the API about the post. + +#### getCommentInfo(post, name, callback) +Get information about a particular comment in a particular post. Callback takes +one argument, information about the given comment. + +### Hooks + +#### link +Posts a summary when either a subreddit, a post or a comment is linked in a +channel. diff --git a/modules/crypto/crypto.js b/modules/crypto/crypto.js new file mode 100644 index 0000000..464a030 --- /dev/null +++ b/modules/crypto/crypto.js @@ -0,0 +1,36 @@ +/** + * Module Name: Flashy + * Description: Makes pages with flashing text and that innit. + */ + +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])); + } + }; + + this.commands['~md5'].regex = /^~md5 ([^ ]+)$/; + this.commands['~sha1'].regex = /^~sha1 ([^ ]+)$/; + this.commands['~sha256'].regex = /^~sha256 ([^ ]+)$/; + this.commands['~aes'].regex = /^~aes "(.*)" "(.*)"$/; +}; + +exports.fetch = function(dbot) { + return new crypto(dbot); +};