Comparing version 1.0.1 to 2.0.0
63
cli.js
@@ -8,41 +8,50 @@ #!/usr/bin/env node | ||
Usage | ||
$ nicepass <size> [...] | ||
$ nicepass <number|hex|phrase> | ||
Options | ||
--passphrase Convert a phrase back into the original byte array | ||
--pretty Output the result as a string | ||
Examples | ||
$ nicepass | ||
[ 'plummet', 'observed', 'electra', 'dripping' ] | ||
$ nicepass 8 | ||
plummet observed electra dripping | ||
$ nicepass --passphrase='selfheal katzenjammer ambidexterity correcter puffer discern' | ||
<Buffer c5 a5 75 a0 03 fd 2b ea ac bc 3a 65> | ||
`, { | ||
boolean: 'pretty' | ||
}); | ||
$ nicepass 05bd809ef433872f | ||
annoying malleably vapory mirk | ||
$ nicepass 'wigglier singing bicyclist clasher barrow haltering twirler asap' | ||
fba4cb24113123240d975fcfea1d085d | ||
`); | ||
const input = cli.input[0]; | ||
try { | ||
if (cli.flags.passphrase) { | ||
const str = cli.flags.passphrase.replace(/['"]+/g, ''); | ||
console.log(niceware.passphraseToBytes(str.split(' '))); | ||
if (!input || typeof input === 'number') { | ||
const size = input || 8; | ||
const arr = niceware.generatePassphrase(size); | ||
console.log(arr.join(' ')); | ||
} else { | ||
let size = 8; | ||
const arr = input.split(' '); | ||
if (cli.input.length > 0) { | ||
size = cli.input[0]; | ||
if (arr.length === 1) { | ||
const str = input.toLowerCase().replace(/[,\s]/g, ''); | ||
const buffer = Buffer.from(str, 'hex'); | ||
const arr = niceware.bytesToPassphrase(buffer); | ||
if (typeof size === 'string') { | ||
throw new TypeError('Expected a number'); | ||
} | ||
} | ||
console.log(arr.join(' ')); | ||
const passphrase = niceware.generatePassphrase(size); | ||
} else { | ||
const str = input.toLowerCase().replace(/['"]+/g, ''); | ||
const byteArray = niceware.passphraseToBytes(str.split(' ')); | ||
let output = ''; | ||
if (cli.flags.pretty) { | ||
console.log(passphrase.join(' ')); | ||
for (let i = 0, j = byteArray.length; i < j; i++) { | ||
let char = byteArray[i].toString(16); | ||
} else { | ||
console.log(passphrase); | ||
if (char.length === 1) { | ||
char = `0${char}`; | ||
} | ||
output += char; | ||
} | ||
console.log(output); | ||
} | ||
@@ -49,0 +58,0 @@ } |
{ | ||
"name": "nicepass", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Generate human-readable passphrases", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -5,3 +5,3 @@ # nicepass [![Build Status](https://travis-ci.org/awcross/nicepass.svg?branch=master)](https://travis-ci.org/awcross/nicepass) | ||
Uses [niceware](https://github.com/diracdeltas/niceware) underneath to generate or convert random bytes into passphrases. | ||
This is a CLI that uses [niceware](https://github.com/diracdeltas/niceware) to generate readable passwords or convert random bytes into a passphrase. | ||
@@ -22,25 +22,23 @@ | ||
Usage | ||
$ nicepass <size> [...] | ||
$ nicepass <number|hex|phrase> | ||
Options | ||
--passphrase Convert a phrase back into the original byte array | ||
--pretty Output the result as a string | ||
Examples | ||
$ nicepass | ||
[ 'plummet', 'observed', 'electra', 'dripping' ] | ||
$ nicepass 8 | ||
plummet observed electra dripping | ||
$ nicepass --passphrase='selfheal katzenjammer ambidexterity correcter puffer discern' | ||
<Buffer c5 a5 75 a0 03 fd 2b ea ac bc 3a 65> | ||
$ nicepass 05bd809ef433872f | ||
annoying malleably vapory mirk | ||
$ nicepass 'wigglier singing bicyclist clasher barrow haltering twirler asap' | ||
fba4cb24113123240d975fcfea1d085d | ||
``` | ||
## Related | ||
## Thanks | ||
- [niceware](https://github.com/diracdeltas/niceware) - API for this module | ||
All credit goes to [yan](https://diracdeltas.github.io/) for creating [niceware](https://github.com/diracdeltas/niceware), the API for this module. | ||
## License | ||
MIT © [Alex Cross](http://alexcross.io) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4159
45
43