-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e15999b
commit bf4698a
Showing
4 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint no-console: 0 */ | ||
|
||
const lib = require('../src'); | ||
|
||
lib.createHash('Buffer') | ||
.then((hash) => console.log(hash)) | ||
.catch((err) => console.error(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
'use strict'; | ||
const crypto = require('crypto'); | ||
|
||
module.exports.hello = (done) => { | ||
return done(null, 'It works!'); | ||
module.exports.createHash = (buffer) => { | ||
return new Promise((resolve, reject) => { | ||
if (!buffer) reject('Buffer not found'); | ||
|
||
const md5 = crypto.createHash('md5').update(buffer).digest('hex'); | ||
const sha1 = crypto.createHash('sha1').update(buffer).digest('hex'); | ||
const sha256 = crypto.createHash('sha256').update(buffer).digest('hex'); | ||
|
||
const hash = { | ||
md5, | ||
sha1, | ||
sha256 | ||
}; | ||
|
||
resolve(hash); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters