Socket
Socket
Sign inDemoInstall

xkpasswd

Package Overview
Dependencies
2
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.7 to 0.0.8

65

cli.js
#! /usr/local/bin/node
var generate = require('./generate');
var parser = require('nomnom')();
var cliParser = require('clarg');
// Define the Application function
var Application = function () {
parser.options({
'complexity': {
position: 0,
default: 3,
help: 'Choose complexity level 1-6 (default: 3)'
},
'separators': {
position: 1,
help: 'Provide a set of custom separators (default: "!@$%^&*-_+=:|~?.;")'
},
'pattern': {
abbr: 'p',
help: 'Specify custom pattern (default: "wswswsdd"). Overrides complexity option.'
},
'number': {
abbr: 'n',
help: 'Generate multiple passwords'
}
});
// Execute the application
var cliArgs = cliParser();
parser.nocommand()
.callback(function (options) {
if (!options.number || typeof options.number !== 'number' || options.number < 1) {
options.number = 1;
} else {
options.number = parseInt(options.number);
}
var options = {
complexity: cliArgs.opts.complexity || cliArgs.opts.c,
separators: cliArgs.opts.separators || cliArgs.opts.s,
pattern: cliArgs.opts.pattern || cliArgs.opts.p,
number: cliArgs.opts.number || cliArgs.opts.n || 1
};
if (options.number === 1) {
console.log('Password:', generate(options));
} else {
console.log('Passwords:\n---------------------------------');
for (i = 0; i < options.number; i++) {
console.log(generate(options));
}
console.log('---------------------------------');
}
options.number = parseInt(options.number);
})
if (typeof options.number !== 'number' || options.number < 1) {
options.number = 1;
}
return parser.parse();
};
// Execute the application
module.exports = Application();
if (options.number === 1) {
console.log('Password:', generate(options));
} else {
console.log('Passwords:\n---------------------------------');
for (i = 0; i < options.number; i++) {
console.log(generate(options));
}
}

@@ -6,4 +6,2 @@ var wordList = require('word-list-json');

random: function (min, max) {
// Returns a random integer between min (included) and max (included)
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
return Math.floor(Math.random() * (max - min + 1)) + min;

@@ -18,2 +16,3 @@ },

// Patterns can consist of any combination of the following: (w)ords, (d)igits, (s)eparators
complexity = complexity || 3;
var rtn = {};

@@ -44,8 +43,11 @@ rtn.separators = '#.-=+';

processOpts: function (opts) {
if (!opts.complexity) opts.complexity = 3;
var predefined = h.resolveComplexity(opts.complexity);
var separators = (opts.separators || predefined.separators);
var rtn = {};
rtn.pattern = (opts.pattern || predefined.pattern);
opts.complexity = parseInt(opts.complexity);
opts.complexity = typeof opts.complexity === 'number' ? opts.complexity : 3;
var predefined = h.resolveComplexity(opts.complexity);
var separators = typeof opts.separators === 'string' ? opts.separators : predefined.separators;
rtn.pattern = opts.pattern || predefined.pattern;
rtn.separator = separators.split('')[h.random(0, separators.length - 1)];

@@ -60,2 +62,3 @@ if (predefined.transform) rtn.transform = predefined.transform;

module.exports = function (opts) {
opts = opts || {};
o = h.processOpts(opts);

@@ -62,0 +65,0 @@ var pattern = o.pattern.split('');

@@ -0,1 +1,6 @@

#!/usr/bin/env node
if (require.main === module) {
return require('./cli');
}
module.exports = require('./generate');
{
"name": "xkpasswd",
"version": "0.0.7",
"description": "Memorable password generator, inspired by a PERL module powering xkpasswd.net/s/",
"version": "0.0.8",
"description": "Memorable password generator",
"main": "index.js",

@@ -24,5 +24,5 @@ "bin": {

"dependencies": {
"nomnom": "^1.8.1",
"clarg": "0.0.2",
"word-list-json": "^0.2.0"
}
}

@@ -0,1 +1,3 @@

# xkpasswd
*Memorable password generator, inspired by a PERL module powering xkpasswd.net/s/*

@@ -29,3 +31,3 @@

```
xkpasswd [complexity] [separators] --pattern --number
xkpasswd --complexity <number> --separators <string> --pattern <string> --number <number>
```

@@ -48,3 +50,3 @@

```
$ xkp 4
$ xkp -c 4

@@ -66,3 +68,3 @@ =join=industrial=wide=direction=lungs=16

```
$ xkp 3 '#!+' -n 5
$ xkp -c 3 -s '#!+' -n 5

@@ -72,6 +74,6 @@ Passwords:

dog!friend!successful!47
he!advice!deer!40
other#sell#close#01
stepped+specific+hurry+00
five#duck#blanket#21
hyperspatial+polyvalences+inquirendo+03
war#reassemble#inventress#93
gainsays+illumes+discontiguity+86
---------------------------------

@@ -85,2 +87,7 @@ ```

v0.0.8
- using a simpler CLI parser
- updated options syntax
v0.0.7

@@ -87,0 +94,0 @@ - replaced random-words module with a more custom solution using word-list-json module

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc