mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-05-02 06:46:07 -04:00
crypto modules
This commit is contained in:
parent
f211c1cbab
commit
5fcb5a5cb9
28 changed files with 122 additions and 7 deletions
17
Cryptography/Block_Ciphers/DES/DES_CFB_example.py
Normal file
17
Cryptography/Block_Ciphers/DES/DES_CFB_example.py
Normal file
|
@ -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)
|
22
Cryptography/Block_Ciphers/DES/DES_ECB_example.py
Normal file
22
Cryptography/Block_Ciphers/DES/DES_ECB_example.py
Normal file
|
@ -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)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue