https://github.com/kbrgl/xkcd-password
A password generator inspired by xkcd comics.
https://github.com/kbrgl/xkcd-password
Last synced: 3 months ago
JSON representation
A password generator inspired by xkcd comics.
- Host: GitHub
- URL: https://github.com/kbrgl/xkcd-password
- Owner: kbrgl
- License: mit
- Created: 2015-09-23T12:42:15.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-25T15:07:44.000Z (over 9 years ago)
- Last Synced: 2025-01-01T12:12:50.617Z (5 months ago)
- Language: Python
- Size: 226 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xkcd password generator

### Languages in which I've implemented this
* Python (compatible with both 2 and 3)
* [Ruby](https://github.com/kbrgl/xkcd-password-rb)### "How the heck do I use this thing?"
If you just want a password then just clone the repo and run the Python script. The script will run on both Python 2 and Python 3 (:D).#### Using the code
1. Initialize the XkcdPasswordGenerator object with the a list of words you want to use.
2. Call the generate() method. It accepts 2 arguments: the number of words, and, optionally, a separator. The words in the returned string will be separated by separator. If you pass in None as a separator, an array is returned instead.Tip: You can retrieve individual words with the random_word() method.
Here's an example:
```python
with open('words.csv') as f:
words = [line for line in f.read().split(sep=',')]generator = XkcdPasswordGenerator(words)
generator.generate() #=> 'correct horse battery staple'
generator.generate(4, None) #=> ['correct', 'horse', 'battery', 'staple']
generator.random_word() #=> 'battery'
```