Skip to content

Commit

Permalink
Adding the base source code and source/binary distributions (sdist an…
Browse files Browse the repository at this point in the history
…d bdist)
  • Loading branch information
Efer committed Nov 5, 2023
1 parent 204602b commit cd3c562
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Private/
passgen.egg-info/
build/
Binary file added dist/passgen-1.0.0-py3-none-any.whl
Binary file not shown.
Binary file added dist/passgen-1.0.0.tar.gz
Binary file not shown.
69 changes: 69 additions & 0 deletions passgen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3

import os
import random
import string
import argparse


def generate_random_string(length=18, use_numbers=True, use_specials=True):
""" This function generates random strings based on arguments you've entered.
Args:
length (int, optional):
The length of the string.
Defaults to 18.
use_numbers (bool, optional):
Don't you need numbers in your string?
Set this to False!
Defaults to True.
use_specials (bool, optional):
Don't you need special characters in your string?
Set this to False!
Defaults to True.
Returns:
A random string.
_type_: <class 'str'>
"""
chars = string.ascii_letters
if use_numbers:
chars += string.digits
if use_specials:
chars += '!@#$%^&*()'

random.seed(os.urandom(1024))
return ''.join(random.choice(chars) for _ in range(length))


def CLI():
parser = argparse.ArgumentParser(
description='This script generates a secure and random string.\n You can use this string as your password or wherever you need a random string.'
)

# Positional arguments
parser.add_argument(
'length',
type=int,
nargs='?',
default=18,
help='Length of the random string',
)
# Optional arguments + -h which stands for help
parser.add_argument(
'-n', '--number',
action='store_false',
help='Exclude numbers in the random string',
)
parser.add_argument(
'-s', '--special',
action='store_false',
help='Exclude special characters in the random string',
)

args = parser.parse_args()

random_string = generate_random_string(
args.length, args.number, args.special
)
print(random_string)
19 changes: 19 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from setuptools import setup, find_packages

setup(
name='passgen',
version='1.0.0',
description='Generate random passwords with customizable options',
author='Efer Barn',
author_email='[email protected]',
packages=find_packages(),
entry_points={
'console_scripts': [
'passgen = Package.passgen:CLI',
],
},
py_modules=['passgen'],
install_requires=[
'argparse',
],
)

0 comments on commit cd3c562

Please sign in to comment.