hubot-hashme
Advanced tools
| var crypto = require('crypto'); | ||
| module.exports = function(algorithm, msg) { | ||
| 'use strict'; | ||
| 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'); | ||
| }; |
+5
-0
@@ -16,2 +16,3 @@ # EditorConfig is awesome: http://EditorConfig.org | ||
| indent_size = 2 | ||
| insert_final_newline = false | ||
@@ -21,1 +22,5 @@ [*.json] | ||
| indent_size = 2 | ||
| insert_final_newline = false | ||
| [*.md] | ||
| insert_final_newline = false |
+5
-2
| 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) { | ||
| }); | ||
| } | ||
| }; |
+5
-4
| { | ||
| "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": {} | ||
| } |
+1
-0
@@ -6,2 +6,3 @@ # hubot-hashme | ||
| [](http://travis-ci.org/tgfjt/hubot-hashme) | ||
| [](http://badge.fury.io/js/hubot-hashme) | ||
@@ -8,0 +9,0 @@ |
+7
-29
@@ -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])); |
+1
-16
| 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'); |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10
11.11%32
3.23%4708
-2.12%63
-19.23%