Skip to content

Commit

Permalink
chore(secretz): remove zlib.createGunzip()
Browse files Browse the repository at this point in the history
since `tar` module can unzip gzipped files automatically
  • Loading branch information
Hax4us authored and ccarruitero committed Aug 19, 2020
1 parent 01a2be1 commit ccf6de8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
9 changes: 4 additions & 5 deletions problems/secretz/problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ You will receive the cipher algorithm name as process.argv[2], the cipher key as
process.argv[3] and the cipher initialization vector as process.argv[4].
You can pass these arguments directly through to `crypto.createDecipheriv()`.

The built-in zlib library you get when you `require('zlib')` has a
`zlib.createGunzip()` that returns a stream for gunzipping.
The `tar` module from npm has a `tar.Parse()` constructor that can unzip gzipped
tar files automatically ( if detected ) and emits `entry` events for each file
in the tar input.

The `tar` module from npm has a `tar.Parse()` function that emits `'entry'`
events for each file in the tar input. Each `entry` object is a readable stream
of the file contents from the archive and:
Each `entry` object is a readable stream of the file contents from the archive and:

`entry.type` is the kind of file ('File', 'Directory', etc)
`entry.path` is the file path
Expand Down
2 changes: 0 additions & 2 deletions problems/secretz/solution.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const crypto = require('crypto')
const tar = require('tar')
const zlib = require('zlib')
const concat = require('concat-stream')

const parser = new tar.Parse()
Expand All @@ -18,5 +17,4 @@ const key = process.argv[3]
const iv = process.argv[4]
process.stdin
.pipe(crypto.createDecipheriv(cipher, key, iv))
.pipe(zlib.createGunzip())
.pipe(parser)
2 changes: 0 additions & 2 deletions test/solutions/secretz.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const crypto = require('crypto')
const tar = require('tar')
const zlib = require('zlib')
const concat = require('concat-stream')

const parser = new tar.Parse()
Expand All @@ -18,5 +17,4 @@ const key = process.argv[3]
const iv = process.argv[4]
process.stdin
.pipe(crypto.createDecipheriv(cipher, key, iv))
.pipe(zlib.createGunzip())
.pipe(parser)

0 comments on commit ccf6de8

Please sign in to comment.