Skip to content

Commit c1b50ab

Browse files
authored
Merge pull request #179 from SoraSpades/master
Resolves #169
2 parents c4fa32a + 8e51608 commit c1b50ab

File tree

6 files changed

+114
-0
lines changed

6 files changed

+114
-0
lines changed

Easy-Password-Generator/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Easy-Password-Generator/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Easy Password Generator
2+
3+
Password generator that uses a wordlist in combination with numbers and symbols to generate a secure but easy to remember password
4+
5+
## Dependancies
6+
7+
You must have [NodeJS](https://nodejs.org/es/) installed.
8+
9+
## Customizing the password
10+
11+
In order to edit the password parameters, open App.js and change the lines 5 to 8 as prefered.
12+
13+
![Parameters Image](images/parameters.png)
14+
15+
## Running the script
16+
17+
To run the script, clone the repository and open this folder. Then run the following command to install the dependencies:
18+
19+
```
20+
$ npm install
21+
```
22+
23+
Then run the following command to generate one password, and rerun it until you get one that you like:
24+
25+
```
26+
$ node app.js
27+
```
28+
29+
## Credits
30+
31+
Programmed by: [SoraSpades](https://github.com/SoraSpades)
32+
33+
Idea by: [Kemystra](https://github.com/Kemystra)
34+
35+
You can also refer the git issue for the origin of this idea: https://github.com/josharsh/100LinesOfCode/issues/169

Easy-Password-Generator/app.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Required library to generate random words
2+
const faker = require('faker')
3+
4+
// Number of characters, numbers and words to generate the password
5+
const WORDS = 2
6+
const CHARACTERS = 1
7+
const NUMBERS = 4
8+
const SEPARATOR = '-'
9+
10+
// Check if the inputs are positive, at least one word is selected and all are integers
11+
if (WORDS < 1 || CHARACTERS < 0 || NUMBERS < 0 || !Number.isInteger(WORDS) || !Number.isInteger(CHARACTERS) || !Number.isInteger(NUMBERS)) {
12+
console.log("Invalid Input")
13+
} else {
14+
// Generate words separated by a hyphen (-)
15+
var pass = faker.random.word()
16+
for (let i = 0; i < WORDS - 1; i++) {
17+
pass += SEPARATOR + faker.random.word()
18+
}
19+
20+
// Some non-alphanumeric characters to append and a function to get one random
21+
const characters = [ "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "_", "-", "+", "=", "|", ":", ";", "<", ",", ">", ".", "?", "/"]
22+
const randomChar = () => characters[Math.floor(Math.random()*characters.length)]
23+
24+
// Append numbers to the end of the word
25+
for (let i = 0; i < NUMBERS; i++) {
26+
let num = Math.floor(Math.random()*10)
27+
pass += num.toString()
28+
}
29+
// Append characters to the beginning of the word
30+
for (let i = 0; i < CHARACTERS; i++) {
31+
pass = randomChar() + pass
32+
}
33+
34+
// Logging out password
35+
console.log("Your password is: " + pass)
36+
}
20.6 KB
Loading

Easy-Password-Generator/package-lock.json

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Easy-Password-Generator/package.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "passgenerator",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "app.js",
6+
"scripts": {
7+
"start": "node app.js"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
"faker": "^5.5.3"
13+
}
14+
}

0 commit comments

Comments
 (0)