diff --git a/Cryptography/PyCrypto/simple_example.py b/Cryptography/Block_Ciphers/AES/aes_simple_example.py similarity index 69% rename from Cryptography/PyCrypto/simple_example.py rename to Cryptography/Block_Ciphers/AES/aes_simple_example.py index 12e0745..4b93c14 100644 --- a/Cryptography/PyCrypto/simple_example.py +++ b/Cryptography/Block_Ciphers/AES/aes_simple_example.py @@ -1,10 +1,5 @@ #!/usr/bin/env python -def example_sha(): - from Crypto.Hash import SHA256 - hash = SHA256.new() - hash.update('message') - print hash.digest() def example_aes(): from Crypto.Cipher import AES @@ -19,5 +14,4 @@ def example_aes(): if __name__ == '__main__': - example_sha() - #example_aes() \ No newline at end of file + example_aes() \ No newline at end of file diff --git a/Cryptography/Block_Ciphers/DES/DES_CFB_example.py b/Cryptography/Block_Ciphers/DES/DES_CFB_example.py new file mode 100644 index 0000000..78c3ef5 --- /dev/null +++ b/Cryptography/Block_Ciphers/DES/DES_CFB_example.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +from Crypto.Cipher import DES +from Crypto import Random + +iv = Random.get_random_bytes(8) + +des1 = DES.new('01234567', DES.MODE_CFB, iv) +des2 = DES.new('01234567', DES.MODE_CFB, iv) +text = 'abcdefghijklmnop' + +cipher_text = des1.encrypt(text) +print cipher_text +print des2.decrypt(cipher_text) diff --git a/Cryptography/Block_Ciphers/DES/DES_ECB_example.py b/Cryptography/Block_Ciphers/DES/DES_ECB_example.py new file mode 100644 index 0000000..fff0ae6 --- /dev/null +++ b/Cryptography/Block_Ciphers/DES/DES_ECB_example.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +from Crypto.Cipher import DES + +def decrypt(key, text): + des = DES.new(key, DES.MODE_ECB) + return des.decrypt(text) + +def encrypt(key, text): + des = DES.new(key, DES.MODE_ECB) + return des.encrypt(text) + +if __name__ == '__main__': + text = "01234567" + key = 'abcdefgh' + print encrypt(key, text) + print + print decrypt(key, text) + diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/README.md b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/README.md similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/README.md rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/README.md diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/client.py b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/client.py similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/client.py rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/client.py diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/md5.py b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/md5.py similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/md5.py rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/md5.py diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/requirements.txt b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/requirements.txt similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/requirements.txt rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/requirements.txt diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/server.py b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/server.py similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/server.py rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/server.py diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/07f1b2b386333435a97f14d828f69d4b03e60f3d.gif b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/07f1b2b386333435a97f14d828f69d4b03e60f3d.gif similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/07f1b2b386333435a97f14d828f69d4b03e60f3d.gif rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/07f1b2b386333435a97f14d828f69d4b03e60f3d.gif diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/3a9f28ab386fe482d4f126969618a9d717b44b86.png b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/3a9f28ab386fe482d4f126969618a9d717b44b86.png similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/3a9f28ab386fe482d4f126969618a9d717b44b86.png rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/3a9f28ab386fe482d4f126969618a9d717b44b86.png diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/611a2426c1622266efe3d377354514c2b0ac6c9b.jpg b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/611a2426c1622266efe3d377354514c2b0ac6c9b.jpg similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/611a2426c1622266efe3d377354514c2b0ac6c9b.jpg rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/611a2426c1622266efe3d377354514c2b0ac6c9b.jpg diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/6ae3619c0c6aa84fbcbcba969fa291f5e6bd224a.png b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/6ae3619c0c6aa84fbcbcba969fa291f5e6bd224a.png similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/6ae3619c0c6aa84fbcbcba969fa291f5e6bd224a.png rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/6ae3619c0c6aa84fbcbcba969fa291f5e6bd224a.png diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/index.html b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/index.html similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/index.html rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/static/xte1C/index.html diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/info.html b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/info.html similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/info.html rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/info.html diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/ok.xml b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/ok.xml similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/ok.xml rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/ok.xml diff --git a/Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/user.xml b/Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/user.xml similarity index 100% rename from Cryptography/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/user.xml rename to Cryptography/Hash_Functions/MD5/Hash-Length-extension-attacks/VimeoHashExploit/templates/user.xml diff --git a/Cryptography/MD5/MD4/md4.py b/Cryptography/Hash_Functions/MD5/MD4/md4.py similarity index 100% rename from Cryptography/MD5/MD4/md4.py rename to Cryptography/Hash_Functions/MD5/MD4/md4.py diff --git a/Cryptography/MD5/brute_force_hex_digest_chars.py b/Cryptography/Hash_Functions/MD5/brute_force_hex_digest_chars.py similarity index 100% rename from Cryptography/MD5/brute_force_hex_digest_chars.py rename to Cryptography/Hash_Functions/MD5/brute_force_hex_digest_chars.py diff --git a/Cryptography/MD5/checksum_file.py b/Cryptography/Hash_Functions/MD5/checksum_file.py similarity index 100% rename from Cryptography/MD5/checksum_file.py rename to Cryptography/Hash_Functions/MD5/checksum_file.py diff --git a/Cryptography/MD5/md5.py b/Cryptography/Hash_Functions/MD5/md5.py similarity index 100% rename from Cryptography/MD5/md5.py rename to Cryptography/Hash_Functions/MD5/md5.py diff --git a/Cryptography/SHA/sha-256-bruteforce.py b/Cryptography/Hash_Functions/SHA/sha-256-bruteforce.py similarity index 100% rename from Cryptography/SHA/sha-256-bruteforce.py rename to Cryptography/Hash_Functions/SHA/sha-256-bruteforce.py diff --git a/Cryptography/SHA/sha-256-bruteforce_remove_123456789x.py b/Cryptography/Hash_Functions/SHA/sha-256-bruteforce_remove_123456789x.py similarity index 100% rename from Cryptography/SHA/sha-256-bruteforce_remove_123456789x.py rename to Cryptography/Hash_Functions/SHA/sha-256-bruteforce_remove_123456789x.py diff --git a/Cryptography/SHA/sha1.py b/Cryptography/Hash_Functions/SHA/sha1.py similarity index 100% rename from Cryptography/SHA/sha1.py rename to Cryptography/Hash_Functions/SHA/sha1.py diff --git a/Cryptography/SHA/sha2.py b/Cryptography/Hash_Functions/SHA/sha2.py similarity index 100% rename from Cryptography/SHA/sha2.py rename to Cryptography/Hash_Functions/SHA/sha2.py diff --git a/Cryptography/Hash_Functions/SHA/sha_simple_example.py b/Cryptography/Hash_Functions/SHA/sha_simple_example.py new file mode 100644 index 0000000..3ad17c3 --- /dev/null +++ b/Cryptography/Hash_Functions/SHA/sha_simple_example.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +def example_sha(): + from Crypto.Hash import SHA256 + hash = SHA256.new() + hash.update('message') + print hash.digest() + +if __name__ == '__main__': + example_sha() \ No newline at end of file diff --git a/Cryptography/Public_Key/RSA.py b/Cryptography/Public_Key/RSA.py new file mode 100644 index 0000000..55055f3 --- /dev/null +++ b/Cryptography/Public_Key/RSA.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + + +from Crypto.PublicKey import RSA +from Crypto import Random + + +def gen_key(nbits=1024): + random_generator = Random.new().read + key = RSA.generate(nbits, random_generator) + return key + +def check_key(key): + print key.can_encrypt() + print key.can_sign() + print key.has_private() + + +def get_pubk(key): + return key.publickey() + + +def encrypt(public_key, text, random): + return public_key.encrypt(text, random) + + +def decrypt(data): + return key.decrypt(enc_data) + + +if __name__ == '__main__': + key = gen_key() + + check_key(key) + + public_key = get_pubk(key) + + text = 'abcdefgh' + enc_data = encrypt(public_key, text, random=32) + print enc_data + + dec_data = decrypt(enc_data) + print dec_data + diff --git a/Cryptography/Public_Key/RSA_sign.py b/Cryptography/Public_Key/RSA_sign.py new file mode 100644 index 0000000..0682ab3 --- /dev/null +++ b/Cryptography/Public_Key/RSA_sign.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + + + +from Crypto.Hash import SHA256 +from Crypto.PublicKey import RSA +from Crypto import Random + +key = RSA.generate(1024) +text = 'abcdefgh' + +hash = SHA256.new(text).digest() +print hash + +signature = key.sign(hash, '') +print signature diff --git a/Cryptography/Stream_Ciphers/arc4.py b/Cryptography/Stream_Ciphers/arc4.py new file mode 100644 index 0000000..35f102e --- /dev/null +++ b/Cryptography/Stream_Ciphers/arc4.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + + +from Crypto.Cipher import ARC4 + +obj1 = ARC4.new('01234567') +obj2 = ARC4.new('01234567') + +text = 'abcdefghijklmnop' +cipher_text = obj1.encrypt(text) +print cipher_text +print obj2.decrypt(cipher_text)