Skip to content

Commit

Permalink
Python challange 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Foryah committed May 8, 2016
1 parent 0855af8 commit 180bdf8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 20 deletions.
48 changes: 28 additions & 20 deletions README.md
@@ -1,53 +1,61 @@
## The Matasano crypto challenges

| [Set 1][set1] | Go Solution | Elixir Solution | C Solution |
|--------------------|-------------------|-------------------|------------------|
| [Challange 1][ch1] | [Solved][ch1go] | [Solved][ch1el] | [Unsolved][ch1c] |
| [Challange 2][ch2] | [Solved][ch2go] | [Solved][ch2el] | [Unsolved][ch2c] |
| [Challange 3][ch3] | [Solved][ch3go] | [Solved][ch3el] | [Unsolved][ch3c] |
| [Challange 4][ch4] | [Unsolved][ch4go] | [Unsolved][ch4el] | [Unsolved][ch4c] |
| [Challange 5][ch4] | [Unsolved][ch5go] | [Unsolved][ch5el] | [Unsolved][ch5c] |
| [Challange 6][ch4] | [Unsolved][ch6go] | [Unsolved][ch6el] | [Unsolved][ch6c] |
| [Challange 7][ch4] | [Unsolved][ch7go] | [Unsolved][ch7el] | [Unsolved][ch7c] |
| [Challange 8][ch4] | [Unsolved][ch8go] | [Unsolved][ch8el] | [Unsolved][ch8c] |

[set1]: http://cryptopals.com/sets/1/
[ch1]: http://cryptopals.com/sets/1/challenges/1/
| [Set 1][set1] | Go Solution | Elixir Solution | C Solution | Python |
|--------------------|-------------------|-------------------|------------------|------------------|
| [Challange 1][ch1] | [Solved][ch1go] | [Solved][ch1el] | [Unsolved][ch1c] | [Unsolved][ch1p] |
| [Challange 2][ch2] | [Solved][ch2go] | [Solved][ch2el] | [Unsolved][ch2c] | [Unsolved][ch2p] |
| [Challange 3][ch3] | [Solved][ch3go] | [Solved][ch3el] | [Unsolved][ch3c] | [Unsolved][ch3p] |
| [Challange 4][ch4] | [Unsolved][ch4go] | [Unsolved][ch4el] | [Unsolved][ch4c] | [Unsolved][ch4p] |
| [Challange 5][ch4] | [Unsolved][ch5go] | [Unsolved][ch5el] | [Unsolved][ch5c] | [Unsolved][ch5p] |
| [Challange 6][ch4] | [Unsolved][ch6go] | [Unsolved][ch6el] | [Unsolved][ch6c] | [Unsolved][ch6p] |
| [Challange 7][ch4] | [Unsolved][ch7go] | [Unsolved][ch7el] | [Unsolved][ch7c] | [Unsolved][ch7p] |
| [Challange 8][ch4] | [Unsolved][ch8go] | [Unsolved][ch8el] | [Unsolved][ch8c] | [Unsolved][ch8p] |

[set1]: http://cryptopals.com/sets/1
[ch1]: http://cryptopals.com/sets/1/challenges/1
[ch1go]: https://github.com/Foryah/cryptopals/commit/bd7e0572f75768b01f2607d91f32f00b8e4afccd
[ch1el]: https://github.com/Foryah/cryptopals/commit/2c46cc983b31a27fce9584f0f2f9f2b0e68343a6
[ch1c]: #
[ch1p]: #

[ch2]: http://cryptopals.com/sets/1/challenges/2/
[ch2]: http://cryptopals.com/sets/1/challenges/2
[ch2go]: https://github.com/Foryah/cryptopals/commit/e8105e94851fff5429481dfdcf95ffeb8765850f
[ch2el]: https://github.com/Foryah/cryptopals/commit/6ad070eec993e99d0965fd0a1adfc7340695e27b
[ch2c]: #
[ch2p]: #

[ch3]: http://cryptopals.com/sets/1/challenges/3/
[ch3]: http://cryptopals.com/sets/1/challenges/3
[ch3go]: https://github.com/Foryah/cryptopals/commit/60cae0a4cd42430bd4eba9415d05b08e9195a75f
[ch3el]: https://github.com/Foryah/cryptopals/commit/d661039b82eb6783575b29b6b344357442925e83
[ch3c]: #
[ch3p]: #

[ch4]: http://cryptopals.com/sets/1/challenges/4/
[ch4]: http://cryptopals.com/sets/1/challenges/4
[ch4go]: #
[ch4el]: #
[ch4c]: #
[ch4p]: #

[ch5]: http://cryptopals.com/sets/1/challenges/5/
[ch5]: http://cryptopals.com/sets/1/challenges/5
[ch5go]: #
[ch5el]: #
[ch5c]: #
[ch5p]: #

[ch6]: http://cryptopals.com/sets/1/challenges/6/
[ch6]: http://cryptopals.com/sets/1/challenges/6
[ch6go]: #
[ch6el]: #
[ch6c]: #
[ch6p]: #

[ch7]: http://cryptopals.com/sets/1/challenges/7/
[ch7]: http://cryptopals.com/sets/1/challenges/7
[ch7go]: #
[ch7el]: #
[ch7c]: #
[ch7p]: #

[ch8]: http://cryptopals.com/sets/1/challenges/8/
[ch8]: http://cryptopals.com/sets/1/challenges/8
[ch8go]: #
[ch8el]: #
[ch8c]: #
[ch8p]: #
Empty file added python/__init__.py
Empty file.
Binary file added python/__pycache__/set1.cpython-35.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions python/set1.py
@@ -0,0 +1,11 @@
import base64
import binascii


def hex2bin_str(hex_str):
return binascii.unhexlify(hex_str)


def hex2b64(hex_str):
bin_str = hex2bin_str(hex_str)
return base64.b64encode(bin_str)
15 changes: 15 additions & 0 deletions python/test_set1.py
@@ -0,0 +1,15 @@
import set1
import unittest


class TestSet1(unittest.TestCase):

def test_challange1(self):
bin_str = set1.hex2bin_str("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d")
self.assertEqual(bin_str.decode("ascii"), "I'm killing your brain like a poisonous mushroom")

bin_str = set1.hex2b64("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d")
self.assertEqual(bin_str.decode("ascii"), "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t")

if __name__ == '__main__':
unittest.main()

0 comments on commit 180bdf8

Please sign in to comment.