Add a cesar python 2 script

This commit is contained in:
Quentin 2018-07-07 18:13:33 +02:00
parent 4568eba742
commit 9be67f4b33
2 changed files with 13 additions and 1 deletions

View File

@ -38,7 +38,7 @@ On avait donc :
decode = (encode + 75) % 128
```
Et voici un script python simple pour réaliser toutes les étapes :
Et voici un script python 3 simple pour réaliser toutes les étapes :
```python
with open('communication_vBZvcbm.txt', 'rb') as f:
@ -52,6 +52,8 @@ with open('communication_vBZvcbm.txt', 'rb') as f:
input()
```
*NB: si vous obtenez un `TypeError: cannot concatenate 'str' and 'int' objects` c'est que vous venez d'exécuter le script avec python 2 au lieu de python 3 ! Il est temps de se mettre à jour ! Si vous insistez, j'ai aussi codé [une version en python 2](/assets/code/cesar-python2.py)*
Le message une fois déchiffré était le suivant :
> Bonjour,

View File

@ -0,0 +1,10 @@
with open('communication_vBZvcbm.txt', 'rb') as f:
all_bytes = f.readlines()
all_bytes = all_bytes[0] + all_bytes[1]
for n in range(1,128):
dec = [0] * len(all_bytes)
for i in range(len(all_bytes)):
dec[i] = (ord(all_bytes[i]) + n) % 128
print(''.join([chr(x) for x in dec]))
raw_input()