hubot-hashme
Advanced tools
Comparing version 0.1.0 to 0.1.1
var fs = require('fs'); | ||
var path = require('path'); | ||
var dir = path.resolve(__dirname, 'src'); | ||
module.exports = function(robot) { | ||
'use strict'; | ||
var dir = path.resolve(__dirname, 'src'); | ||
fs.exists(dir, function(exists) { | ||
@@ -12,2 +15,2 @@ if (exists) { | ||
}); | ||
} | ||
}; |
{ | ||
"name": "hubot-hashme", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "tgfjt", | ||
@@ -19,9 +19,10 @@ "description": "to create hash with crypto for hubot", | ||
"bugs": { | ||
"email": "fujita@tagpanda.co.jp", | ||
"email": "tgfjt.mail@gmail.com", | ||
"url": "https://github.com/tgfjt/hubot-hashme/issues" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"devDependencies": { | ||
"tape": "~2.12.0" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
@@ -6,2 +6,3 @@ # hubot-hashme | ||
[![Build Status](https://secure.travis-ci.org/tgfjt/hubot-hashme.png?branch=master)](http://travis-ci.org/tgfjt/hubot-hashme) | ||
[![NPM version](https://badge.fury.io/js/hubot-hashme.png)](http://badge.fury.io/js/hubot-hashme) | ||
@@ -8,0 +9,0 @@ |
@@ -1,33 +0,11 @@ | ||
/** | ||
* Description: | ||
* Hash me!! | ||
* | ||
* Dependencies: | ||
* "crypto": "0.0.3" | ||
* | ||
* Commands: | ||
* hubot hashme <algorithm> <phrase> - to create hash from phrase. | ||
*/ | ||
// Description: | ||
// Hash me!! | ||
// Commands: | ||
// hubot hashme <algorithm> <phrase> - to create hash from phrase. | ||
var hashMe = require('../lib/hashme'); | ||
var crypto, hashMe; | ||
crypto = require('crypto'); | ||
module.exports = function(robot) { | ||
'use strict'; | ||
hashMe = function(algorithm, msg) { | ||
var errMsg, hash, hashList; | ||
errMsg = ''; | ||
hashList = ['sha1', 'md5', 'sha256', 'sha512']; | ||
if (hashList.indexOf(algorithm) === -1) { | ||
errMsg = 'algorithm should to be... ' + hashList.join(', '); | ||
return errMsg; | ||
} | ||
hash = crypto.createHash(algorithm); | ||
hash.update(msg); | ||
return hash.digest('hex'); | ||
}; | ||
module.exports = function(robot) { | ||
robot.respond(/hashme (.*) (.*)/i, function(msg) { | ||
@@ -34,0 +12,0 @@ return msg.send(hashMe(msg.match[1], msg.match[2])); |
var test = require('tape'); | ||
var crypto = require('crypto'); | ||
var hashMe = require('../lib/hashme'); | ||
var hashMe = function(algorithm, msg) { | ||
var errMsg, hash, hashList; | ||
errMsg = ''; | ||
hashList = ['sha1', 'md5', 'sha256', 'sha512']; | ||
if (hashList.indexOf(algorithm) === -1) { | ||
errMsg = 'algorithm should to be... ' + hashList.join(', '); | ||
return errMsg; | ||
} | ||
hash = crypto.createHash(algorithm); | ||
hash.update(msg); | ||
return hash.digest('hex'); | ||
}; | ||
test('hashme wrong algorithm', function (t) { | ||
@@ -22,0 +7,0 @@ var wrong = hashMe('hoge', '123'); |
Sorry, the diff of this file is not supported yet
10
32
4708
63