0%

密码学基础

密码学基础

des

1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env python
from Crypto.Cipher import DES

key = 'Assassin'
flag = 'flag{teeeeeeest}'
obj = DES.new(key, DES.MODE_ECB)
enc = obj.encrypt(flag)
print list(enc)
plain = obj.decrypt(enc)
print plain

AES

1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env python
from Crypto.Cipher import AES

key = 'AssassinQ_______'
iv = 'AssassinQ_______'
flag = 'flag{teeeeeeest}'
obj = AES.new(key, AES.MODE_CBC, iv)
enc = obj.encrypt(flag)
print list(enc)
obj = AES.new(key, AES.MODE_CBC, iv)
plain = obj.decrypt(enc)
print plain

blowFish

1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env python
from Crypto.Cipher import Blowfish

key = 'AssassinQ'
flag = 'flag{teeeeeeest}'
obj = Blowfish.new(key, Blowfish.MODE_ECB)
enc = obj.encrypt(flag)
print list(enc)
plain = obj.decrypt(enc)
print plain

rc2

1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env python
from Crypto.Cipher import ARC2

key = 'AssassinQ_______'
iv = 'Assassin'
flag = 'flag{teeeeeeest}'
obj = ARC2.new(key, ARC2.MODE_CFB, iv)
enc = obj.encrypt(flag)
print list(enc)
obj = ARC2.new(key, ARC2.MODE_CFB, iv)
plain = obj.decrypt(enc)
print plain

cast-128

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env python
from Crypto.Cipher import CAST

key = 'AssassinQ_______'
iv = 'Assassin'
flag = 'flag{teeeeeeest}'
obj = CAST.new(key, CAST.MODE_OPENPGP, iv)
enc = obj.encrypt(flag)
print list(enc)

eiv = enc[:CAST.block_size + 2]
obj = CAST.new(key, CAST.MODE_OPENPGP, eiv)
plain = obj.decrypt(enc[CAST.block_size + 2:])
print plain

本文作者:NoOne
本文地址https://noonegroup.xyz/posts/c0dd6f2c/
版权声明:转载请注明出处!