Small library for generating XKCD style passphrases
Project description
# (correcthorse)batterystaple
Small library for generating XKCD style passphrases. (http://xkcd.com/936/)
Word list sourced from: https://github.com/atebits/Words
In addition to generating a passphrase, by default the `generate` function logs some
basic analysis of the difficulty of cracking the password based on the number of candidate
words used in generating the passphrase.
## Usage Examples
Calling `generate` with no arguments:
```python
In [0]: from batterystaple import generate
In [1]: generate()
Generating passphrase of length 4 from 274907 candidate words...
Passphrase generated.
Number of possible passphrases with given length and constraints: 5,711,408,111,099,032,105,201
Time required to try all combinations at speed of 1 billion attempts/second: 5,711,408,111,099s
For the sake of comparison, here are several other lengths of time:
Seconds in one year: 31,557,600s
Seconds since UNIX epoch (Jan 1, 1970 12:00:00am): 1,416,230,980s
Seconds since humans emerged as a distinct species: 6,311,520,000,000s
Seconds since the universe formed: 435,494,880,000,000,000s
Out[1]: 'nonviable_gratification_workbench_subdwarfs'
```
Limiting candidate words to between 4 and 8 characters each:
```python
In [0]: from batterystaple import generate
In [1]: generate(min_length=4,max_length=8)
Eliminating all words less than 4 characters in length...
1435 words removed from list of candidates.
Eliminating all words greater than 8 characters in length...
158943 words removed from list of candidates.
Generating passphrase of length 4 from 114529 candidate words...
Passphrase generated.
Number of possible passphrases with given length and constraints: 172,052,851,568,492,369,281
Time required to try all combinations at speed of 1 billion attempts/second: 172,052,851,568s
For the sake of comparison, here are several other lengths of time:
Seconds in one year: 31,557,600s
Seconds since UNIX epoch (Jan 1, 1970 12:00:00am): 1,416,230,980s
Seconds since humans emerged as a distinct species: 6,311,520,000,000s
Seconds since the universe formed: 435,494,880,000,000,000s
Out[1]: 'visards_gentlest_inmost_imbued'
```
Generating a passphrase consisting of 5 words with no underscores
in the returned string:
```python
In [0]: from batterystaple import generate
In [1]: generate(num_words=5,with_underscores=False)
Generating passphrase of length 5 from 274907 candidate words...
Passphrase generated.
Number of possible passphrases with given length and constraints: 1,570,106,069,597,901,618,944,491,307
Time required to try all combinations at speed of 1 billion attempts/second: 1,570,106,069,597,901,568s
For the sake of comparison, here are several other lengths of time:
Seconds in one year: 31,557,600s
Seconds since UNIX epoch (Jan 1, 1970 12:00:00am): 1,416,230,980s
Seconds since humans emerged as a distinct species: 6,311,520,000,000s
Seconds since the universe formed: 435,494,880,000,000,000s
Out[1]: 'headwaysmaterialisehandstandssjambokingalpinists'
```
And finally, limiting log output:
```python
In [0]: import logging
In [1]: from batterystaple import generate
In [2]: generate(log_level=logging.WARN)
Out[2]: 'cherisher_knobbiness_yardages_teinded'
In [3]: generate(log_level=logging.ERROR)
Out[3]: 'eider_scarabaeoid_heartsome_unsleeping'
```
Small library for generating XKCD style passphrases. (http://xkcd.com/936/)
Word list sourced from: https://github.com/atebits/Words
In addition to generating a passphrase, by default the `generate` function logs some
basic analysis of the difficulty of cracking the password based on the number of candidate
words used in generating the passphrase.
## Usage Examples
Calling `generate` with no arguments:
```python
In [0]: from batterystaple import generate
In [1]: generate()
Generating passphrase of length 4 from 274907 candidate words...
Passphrase generated.
Number of possible passphrases with given length and constraints: 5,711,408,111,099,032,105,201
Time required to try all combinations at speed of 1 billion attempts/second: 5,711,408,111,099s
For the sake of comparison, here are several other lengths of time:
Seconds in one year: 31,557,600s
Seconds since UNIX epoch (Jan 1, 1970 12:00:00am): 1,416,230,980s
Seconds since humans emerged as a distinct species: 6,311,520,000,000s
Seconds since the universe formed: 435,494,880,000,000,000s
Out[1]: 'nonviable_gratification_workbench_subdwarfs'
```
Limiting candidate words to between 4 and 8 characters each:
```python
In [0]: from batterystaple import generate
In [1]: generate(min_length=4,max_length=8)
Eliminating all words less than 4 characters in length...
1435 words removed from list of candidates.
Eliminating all words greater than 8 characters in length...
158943 words removed from list of candidates.
Generating passphrase of length 4 from 114529 candidate words...
Passphrase generated.
Number of possible passphrases with given length and constraints: 172,052,851,568,492,369,281
Time required to try all combinations at speed of 1 billion attempts/second: 172,052,851,568s
For the sake of comparison, here are several other lengths of time:
Seconds in one year: 31,557,600s
Seconds since UNIX epoch (Jan 1, 1970 12:00:00am): 1,416,230,980s
Seconds since humans emerged as a distinct species: 6,311,520,000,000s
Seconds since the universe formed: 435,494,880,000,000,000s
Out[1]: 'visards_gentlest_inmost_imbued'
```
Generating a passphrase consisting of 5 words with no underscores
in the returned string:
```python
In [0]: from batterystaple import generate
In [1]: generate(num_words=5,with_underscores=False)
Generating passphrase of length 5 from 274907 candidate words...
Passphrase generated.
Number of possible passphrases with given length and constraints: 1,570,106,069,597,901,618,944,491,307
Time required to try all combinations at speed of 1 billion attempts/second: 1,570,106,069,597,901,568s
For the sake of comparison, here are several other lengths of time:
Seconds in one year: 31,557,600s
Seconds since UNIX epoch (Jan 1, 1970 12:00:00am): 1,416,230,980s
Seconds since humans emerged as a distinct species: 6,311,520,000,000s
Seconds since the universe formed: 435,494,880,000,000,000s
Out[1]: 'headwaysmaterialisehandstandssjambokingalpinists'
```
And finally, limiting log output:
```python
In [0]: import logging
In [1]: from batterystaple import generate
In [2]: generate(log_level=logging.WARN)
Out[2]: 'cherisher_knobbiness_yardages_teinded'
In [3]: generate(log_level=logging.ERROR)
Out[3]: 'eider_scarabaeoid_heartsome_unsleeping'
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
batterystaple-0.1.0dev1.tar.gz
(720.1 kB
view details)
Built Distribution
File details
Details for the file batterystaple-0.1.0dev1.tar.gz
.
File metadata
- Download URL: batterystaple-0.1.0dev1.tar.gz
- Upload date:
- Size: 720.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4a6bcf60827f6811e35f6d59036eda0829338cf1a9e77f84d3d9ee264105348 |
|
MD5 | 4958c40c4dc5c37335f88b0940cf69c4 |
|
BLAKE2b-256 | e50bf578151c0d6d9e07d3aef8a01976fe15c86c3f6a5776f4c57b72c2721d73 |
File details
Details for the file batterystaple-0.1.0dev1-py2.py3-none-any.whl
.
File metadata
- Download URL: batterystaple-0.1.0dev1-py2.py3-none-any.whl
- Upload date:
- Size: 721.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbebd46c90e11258900d29cc3535a353e832021317ed732806ca903b3763e0fe |
|
MD5 | f671d21ea273f1caf504f8fe92f66c95 |
|
BLAKE2b-256 | 27ce04781ca6fde3f464998c44daf2cf39f8b028968564e2ee3d89789f118503 |