Skip to content

Commit

Permalink
Refactor CLI to use node crypto for hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
VerHde committed Nov 6, 2021
1 parent fdd26d1 commit a9869e9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 180 deletions.
178 changes: 0 additions & 178 deletions Sha256.js

This file was deleted.

4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import emojify from './emojify.js'
import Sha256 from './Sha256.js'
import crypto from 'crypto'
import readline from 'readline'

console.log('Type something in to generate it\'s sha256 hash and an emoji representation of that.')
Expand All @@ -13,7 +13,7 @@ const rl = readline.createInterface({
rl.prompt()

rl.on('line', (line) => {
const hash = Sha256.hash(line.trim())
const hash = crypto.createHash('sha256').update(line.trim()).digest('hex')
const emojis = emojify(hash)

console.log(
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('CLI', function () {
assert.ok(npmReturn.includes(outputHash))
assert.ok(npmReturn.includes(outputEmojis))
})

it('works with `npm run cli` and `node cli.js` equally', function () {
assert.equal(
nodeReturn.split('\n')[resultIndex],
Expand Down

0 comments on commit a9869e9

Please sign in to comment.