mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
Merge pull request #85 from Hafpaf/master
add Pseudorandom password generator
This commit is contained in:
commit
2a9b23a6c9
|
@ -43,6 +43,7 @@ So far, the following projects have been integrated to this repo:
|
||||||
|[Port Scanner](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Port_Scanner)|[Plutoberth](https://github.com/Plutoberth)|
|
|[Port Scanner](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Port_Scanner)|[Plutoberth](https://github.com/Plutoberth)|
|
||||||
|[Python Algebra Solver](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Algebra-Solver)|[Sengxay Xayachack](https://github.com/frankxayachack)|
|
|[Python Algebra Solver](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Algebra-Solver)|[Sengxay Xayachack](https://github.com/frankxayachack)|
|
||||||
|[Random name generator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Random_Names_Generator)| [Ayush Bhardwaj](https://github.com/hastagAB)|
|
|[Random name generator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Random_Names_Generator)| [Ayush Bhardwaj](https://github.com/hastagAB)|
|
||||||
|
|[Random Password Generators](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Random_Password_Generator)| [Hafpaf](https://github.com/hafpaf) and [Renderer-RCT2](https://github.com/Renderer-RCT2)|
|
||||||
|[Server Ping](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Ping_Server)|[prince]()|
|
|[Server Ping](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Ping_Server)|[prince]()|
|
||||||
|[Signature photo to PNG converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/signature2png)|[Rodolfo Ferro](https://github.com/RodolfoFerro)|
|
|[Signature photo to PNG converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/signature2png)|[Rodolfo Ferro](https://github.com/RodolfoFerro)|
|
||||||
|[Simple Webpage Parser](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/SimpleWebpageParser)|[Nitish Srivastava](https://github.com/nitish-iiitd)|
|
|[Simple Webpage Parser](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/SimpleWebpageParser)|[Nitish Srivastava](https://github.com/nitish-iiitd)|
|
||||||
|
|
|
@ -1,9 +1,18 @@
|
||||||
# Random Password Generator
|
# Programs
|
||||||
|
## [PasswordGenerator.py](./PasswordGenerator.py)
|
||||||
This program randomly generates a secure password using a mix of letters, both caps on and off, numbers, and punctuation, then outputs the results and saves them as a text document.
|
This program randomly generates a secure password using a mix of letters, both caps on and off, numbers, and punctuation, then outputs the results and saves them as a text document.
|
||||||
|
|
||||||
# Requirements
|
## [createPassword.py](./createPassword.py)
|
||||||
|
This program uses the Python 3 module `secrets` to create a pseudo random password with alphanumeric, numbers, and special characters. The output will be printed into the terminal.
|
||||||
|
|
||||||
Python 3 and higher or Python 2 and higher
|
# Requirements
|
||||||
|
* [PasswordGenerator.py](./PasswordGenerator.py) can use Python 3 and higher or Python 2 and higher
|
||||||
|
* [createPassword.py](./createPassword.py) can run on python 3.6 or higher or for Python 2 do:
|
||||||
|
* `cd Random_Password_Generator/` to change directory into this folder.
|
||||||
|
* Create virtual environment with `virtualvenv env`
|
||||||
|
* do `source venv/bin/activate` to activate virtual environment.
|
||||||
|
* do `pip install -r requirements.txt` to install python2-secrets
|
||||||
|
* **TIP**: to deactivate virtual environment, do `deactivate`.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
|
|
23
Random_Password_Generator/createPassword.py
Normal file
23
Random_Password_Generator/createPassword.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# <Summary>Create a pseudo random password with alphanumeric, numbers, and special characters</summary>
|
||||||
|
|
||||||
|
import secrets #implemented in python version 3.6+
|
||||||
|
|
||||||
|
#String of characters
|
||||||
|
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-=_+`~[]{]\|;:,<.>/?'
|
||||||
|
|
||||||
|
#2 for loops should be O(n²) runtime
|
||||||
|
def create(number_of_passwords, pass_length):
|
||||||
|
for i in range(number_of_passwords):
|
||||||
|
list = [] # create new empty list
|
||||||
|
for i in range(pass_length):
|
||||||
|
select = secrets.choice(chars) #the secret sauce to select a pseudo random character
|
||||||
|
list.append(select) #add pseudo random char to list
|
||||||
|
l = ''.join(list) #concatenate list to string for every ''
|
||||||
|
print(l) #<-- comment me out for faster computing
|
||||||
|
return l
|
||||||
|
|
||||||
|
#Run function
|
||||||
|
create(int(5),int(20)) #number_of_passwords, pass_length
|
1
Random_Password_Generator/requirements.txt
Normal file
1
Random_Password_Generator/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
python2-secrets>=1.0.5
|
Loading…
Reference in New Issue
Block a user