From a2ef4ba0b11a6632514fb29818a6c9f2621e72ec Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Wed, 25 Nov 2009 17:10:32 -0500 Subject: [PATCH] first failing version :) --- .gitignore | 1 + onetimepad.py | 8 ++++++++ setup.py | 23 +++++++++++++++++++++++ test_onetimepad.py | 21 +++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/onetimepad.py b/onetimepad.py index e69de29..90d81bf 100644 --- a/onetimepad.py +++ b/onetimepad.py @@ -0,0 +1,8 @@ + + +def encode(msg, pad): + return msg + + +def decode(msg, pad): + return msg diff --git a/setup.py b/setup.py index e69de29..dc9b021 100644 --- a/setup.py +++ b/setup.py @@ -0,0 +1,23 @@ +import sys +from distutils.core import setup + + +SETUP_ARGS = dict( + name='OneTimePad', + version='0.1.0', + author='Dan Buch', + author_email='daniel.buch@gmail.com', + url='http://github.com/meatballhat/OneTimePad', + description='one-time pad cryptosystem described in "Cryptonomicon"', + long_description='', + py_modules=['onetimepad'], +) + + +def main(): + setup(**SETUP_ARGS) + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/test_onetimepad.py b/test_onetimepad.py index e69de29..eccb25f 100644 --- a/test_onetimepad.py +++ b/test_onetimepad.py @@ -0,0 +1,21 @@ +import random + +import unittest +import onetimepad as OT + + +class TestOneTimePad(unittest.TestCase): + pad = 'THISISMYONETIMEPADANDITISNOTESPECIALLYBIG' \ + 'BUTITISBIGENOUGHFORMYUSESIFYOUDONTMINDTHX' + + def test_encode(self): + enc = OT.encode(IN_MSG, self.pad) + self.assertEqual(EXPECTED_ENCODED, enc) + + def test_decode(self): + dec = OT.decode(EXPECTED_ENCODED, self.pad) + self.assertEqual(IN_MSG, dec) + + +IN_MSG = 'TWOBYFOURBOARDSONEHUNDREDCOUNTLENGTHEIGHTFEET' +EXPECTED_ENCODED = 'huteshusoahutseohusoaeutoaehusoat'