comparison docs/index.rst @ 55:9341896b93f0

Added library tutorial documentation.
author Brian Neal <bgneal@gmail.com>
date Fri, 05 Jul 2013 19:32:45 -0500
parents 7fd3ec5580ab
children 21627ec5b1ad
comparison
equal deleted inserted replaced
54:7fd3ec5580ab 55:9341896b93f0
142 more details, consult the command-line ``m209`` documentation. 142 more details, consult the command-line ``m209`` documentation.
143 143
144 Library Tutorial 144 Library Tutorial
145 ---------------- 145 ----------------
146 146
147 Here is one way to perform the encrypt and decrypt operations from the
148 command-line tutorial, above. In order to produce the same output, we explicity
149 specify the encryption parameters: the key list, the external message
150 indicator, and the system indicator. These parameters are explained in the
151 reference documentation.
152
153 .. literalinclude:: ../examples/encrypt.py
154
155 This program outputs::
156
157 IIPDU FHLMB LASGD KTLDO OSRMZ PWGEB HYMCB IKSPT IUEPF FUHEO NQTWI VTDPC GSPQX IIPDU FHLMB
158
159 A decrypt is just a bit more complicated. After constructing a ``StdProcedure``
160 object, you hand it the encrypted message to analyze. The procedure object
161 examines the groups in the message and extracts all the indicators. These are
162 returned as a ``DecryptParams`` named tuple which indicates, amongst other
163 things, what key list is required. It is then up to you to obtain this key list
164 somehow. Here we use the ``read_key_list()`` function to do so. After
165 installing the key list into the procedure object, you can finally call
166 ``decrypt()``:
167
168 .. literalinclude:: ../examples/decrypt.py
169
170 This program prints::
171
172 THE PI A HAS ARRIVED STOP NO SIGN OF ENEMY FORCES STOP
173
174
147 Requirements 175 Requirements
148 ------------ 176 ------------
149 177
150 ``m209`` is written in Python_, specifically Python 3.3. It has no other 178 ``m209`` is written in Python_, specifically Python 3.3. It has no other
151 requirements or dependencies. 179 requirements or dependencies.
152 180
181
153 Installation 182 Installation
154 ------------ 183 ------------
155 184
156 ``m209`` is available on the `Python Package Index`_ (PyPI). You can install it 185 ``m209`` is available on the `Python Package Index`_ (PyPI). You can install it
157 using pip_:: 186 using pip_::
158 187
159 $ pip install m209 # install 188 $ pip install m209 # install
160 $ pip install --upgrade m209 # upgrade 189 $ pip install --upgrade m209 # upgrade
161 190
162 You may also download a tarball or .zip file of the latest code using the "get 191 You may also download a tarball or .zip file of the latest code by visiting the
163 source" link on the `m209 Bitbucket page`_. Alternatively if you use 192 Downloads tab on the `m209 Bitbucket page`_. Alternatively if you use
164 Mercurial_, you can clone the repository with the following command:: 193 Mercurial_, you can clone the repository with the following command::
165 194
166 $ hg clone https://bitbucket.org/bgneal/m209 195 $ hg clone https://bitbucket.org/bgneal/m209
167 196
168 If you did not use pip, you can install with this command:: 197 If you did not use pip, you can install with this command::