A large wordlist is provided (courtesy of `12Dicts <http://wordlist.aspell.net/12dicts/>`_) for convenience, but the generator can be used with any word file of the correct format: a file containing one 'word' per line. The default word file can be found in ``xkcdpass/static/default.txt``.
-The main script can also be imported into other python code, and an example of this usage is provided in the package (``xkcdpass/example_import.py``).
+
+
+Advanced Usage
+==============
+
+The built-in functionality of ``xkcdpass`` can be extended by importing the module into custom python scripts.
+An example of this usage is provided in `example_import.py <https://github.com/redacted/XKCD-password-generator/blob/master/xkcdpass/example_import.py>`_, which randomly capitalises the letters in a generated password.
+
+A simple use of import::
+
+ import xkcdpass.xkcd_password as xp
+
+ ## create a wordlist from the default wordfile
+ ## use words between 5 and 8 letters long
+ wordfile = xp.locate_wordfile()
+ mywords = xp.generate_wordlist(wordfile=wordfile, min_length=5, max_length=8)
+
+ ## create a password with the acrostic "face"
+ print(xp.generate_xkcdpassword(mywords, acrostic="face"))
License
=======
-The BSD License (BSD)
\ No newline at end of file
+The BSD License (BSD)
-# import the generate_xkcdpassword and generate_wordlist functions
-from xkcd_password import generate_wordlist, generate_xkcdpassword
+import xkcdpass.xkcd_password as xp
+import random
-# create a wordlist
-mywords = generate_wordlist(wordfile='3esl.txt', min_length=5, max_length=8,)
+## create a wordlist
+#mywords = generate_wordlist(wordfile='3esl.txt', min_length=5, max_length=8,)
-# create a password with the acrostic 'face'
-print(generate_xkcdpassword(mywords, acrostic="face"))
+## create a password with the acrostic 'face'
+#print(generate_xkcdpassword(mywords, acrostic="face"))
+
+def random_capitalisation(s, chance):
+ new_str = []
+ for i, c in enumerate(s):
+ new_str.append(c.upper() if random.random() < chance else c)
+ return "".join(new_str)
+
+
+words = xp.locate_wordfile()
+mywords = xp.generate_wordlist(wordfile=words, min_length=5, max_length=8)
+raw_password = xp.generate_xkcdpassword(mywords)
+
+for i in range(5):
+ print random_capitalisation(raw_password, i/10.0)