Skip to content

Commit 4078a64

Browse files
author
CosmoSt4r
committed
Added Readme
1 parent d8e7141 commit 4078a64

File tree

3 files changed

+122
-11
lines changed

3 files changed

+122
-11
lines changed

README.md

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,111 @@
1-
# pypasswords
2-
Easy working with passwords in python
1+
# Pypasswords - work with passwords easily.
2+
3+
Pypasswords provides easy hashing, checking and generating passwords for you.
4+
5+
# Overview
6+
7+
- Hash passwords using your favourite hashing algorithms
8+
- Check passwords for strength or validity
9+
- Generate passwords with your own parameters
10+
11+
## Installation
12+
13+
To install this package you can use Pypi via pip
14+
15+
```
16+
$ pip install pypasswords
17+
```
18+
19+
## Usage
20+
21+
First you need to import all methods from this package
22+
23+
```py
24+
from pypasswords import hash_it, check_it, generate_it
25+
```
26+
... or simply
27+
28+
```py
29+
from pypasswords import *
30+
```
31+
32+
#### Hashing
33+
34+
You can easily hash your password with just one line of code:
35+
36+
```py
37+
hash_it('qwerty')
38+
```
39+
40+
**hash_it** method has the following parameters:
41+
* **password** - (string)
42+
* **hash_type** - (string). *Optional*. Use to specify hashing algorithm. Default: *sha-256*
43+
* **salting** - (bool). *Optional*. Use to specify whether to use salt or not. More [here](https://en.wikipedia.org/wiki/Salt_(cryptography)). Default: *False*. Warning: if you specify salt=*True* then the method will generate random salt and return both the hash and the salt.
44+
* **static_salt** - (string). *Optional*. Use to specify your own salt.
45+
* **salt_length** - (int). *Optional*. Use to specify the length of the salt. Default: *6*
46+
* **local_parameter** - (string). *Optional*. Use to specify local parameter. More [here](https://www.openwall.com/presentations/YaC2012-Password-Hashing-At-Scale/mgp00005.html).
47+
48+
##### Examples:
49+
50+
```py
51+
hash_it('qwerty', hash_type='sha512')
52+
hash_it('qwerty', salting=True, static_salt='some_word')
53+
hash_it('qwerty', salting=True, salt_length=10, local_parameter='word')
54+
```
55+
56+
#### Checking
57+
58+
You can check your password for strength or validity:
59+
60+
```py
61+
check_it('qwerty')
62+
```
63+
64+
**check_it** method has the following parameters:
65+
* **password** - (string)
66+
* **check_type** - (string). *Optional*. There are 2 check types: strength and valid. Default: *strength*
67+
- *strength* check type will return number 0-100 indicating strength of your password. If strength more than 30 then the password is good.If strength more than 50 then the password is strong.
68+
- *valid* check type will return True or False whether password has 'stop chars' or not. You have to specify *stop_chars* to use this check type.
69+
* **stop_chars** - (string). *Optional*. Use to specify stop characters to check your password for validity.
70+
71+
##### Examples:
72+
73+
```py
74+
check_it('123some-password321')
75+
check_it('qwerty', check_type='valid', stop_chars='0123456789')
76+
```
77+
78+
#### Generating
79+
80+
You can generate password with your own parameters:
81+
82+
```py
83+
generate_it()
84+
```
85+
86+
**generate_it** method has the following parameters:
87+
* **strength** - (int). *Optional*. Defalut: *2*
88+
- **1** - *low*. Using letters only.
89+
- **2** - *medium*. Using letters and numbers.
90+
- **3** - *high*. Using letters, numbers and symbols.
91+
* **length** - (int). *Optional*. Use to specify password length. Default: *12*
92+
93+
##### Examples:
94+
95+
```py
96+
generate_it(strength=2)
97+
generate_it(strength=3, length=3)
98+
```
99+
100+
License
101+
----
102+
103+
MIT
104+
105+
#
106+
Pypasswords uses one open source package to work properly:
107+
108+
* [zxcvbn](https://github.com/dropbox/zxcvbn) - password strength estimator
109+
110+
And of course **pypasswords** itself is open source with a [public repository](https://github.com/CosmoSt4r/pypasswords)
111+
on GitHub.

pypasswords/main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def salt_password(word, static, length):
2828
salt = ''
2929
for _ in range(length):
3030
salt += choice(salt_dictionary)
31-
return word + salt
31+
return word + salt, salt
3232
else:
3333
# using static_salt
3434
salt = static
35-
return word + salt
35+
return word + salt, salt
3636

3737
def add_local_parameter(word, parameter):
3838

@@ -41,13 +41,16 @@ def add_local_parameter(word, parameter):
4141

4242
# main function to hash the password
4343
if salting:
44-
password = salt_password(password, static_salt, salt_length)
44+
password, salt = salt_password(password, static_salt, salt_length)
4545

4646
if local_parameter:
4747
password = add_local_parameter(password, local_parameter)
4848

4949
password = hash_password(password, hash_type)
50-
return password
50+
if salting:
51+
return password, salt
52+
else:
53+
return password
5154

5255

5356
def check_it(password, check_type='strength', stop_chars=''):

setup.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22
setup(
33
name = 'pypasswords',
44
packages = ['pypasswords'],
5-
version = '0.2',
5+
version = '0.3',
66
license='MIT',
77
description = 'Working with passwords made simple',
88
author = 'CosmoStar',
99
author_email = 'JustCosmos@yandex.ru',
1010
url = 'https://github.com/CosmoSt4r/pypasswords',
11-
download_url = 'https://github.com/CosmoSt4r/pypasswords/archive/v_02.tar.gz',
11+
download_url = 'https://github.com/CosmoSt4r/pypasswords/archive/v_03.tar.gz',
1212
keywords = ['password', 'passwords', 'check', 'hash', 'simple'],
1313
install_requires=[
14-
'hashlib',
1514
'zxcvbn',
1615
],
1716
classifiers=[
1817

19-
'Development Status :: 3 - Alpha',
18+
'Development Status :: 2 - Beta',
2019

2120
'Intended Audience :: Developers',
22-
'Topic :: Software Development :: Build Tools',
21+
'Security :: Cryptography',
2322

2423
'License :: OSI Approved :: MIT License',
2524

0 commit comments

Comments
 (0)