Advertisement
JpRuEcIQedVCHB

Untitled

Dec 30th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.17 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. from enigmini import Enigmini
  4. from secretpy import CryptMachine
  5.  
  6. def encdec(cipher, plaintext, key):
  7.     print('=' * 80)
  8.     print(plaintext)
  9.     enc = cipher.encrypt(plaintext, key)
  10.     print(enc)
  11.     print(cipher.decrypt(enc, key))
  12.  
  13.  
  14. key = {
  15.     'square': 'ON1CSXIGL3HT5ZRA8DP6WE2JFKU0YQ97B4MV',
  16.     'reflector': 'KP',
  17.     'rotor_offsets': (0, 0), # Grundstellung
  18.     'ring_offsets': (0, 0), # Ringstellung
  19.     'rotor_order': ('KP_II', 'KP_I'),
  20.     'steckers': []
  21. }
  22.  
  23. cipher = Enigmini()
  24.  
  25. #plaintext = "DEZE VOORBEELDTEKST IS VERCIJFERD MET DE ENIGMINI!"
  26. #encdec(cipher, plaintext, key)
  27.  
  28. code_opgave_b = "UCXOMDTVHMAXJCO6PKSJJ5P4Y18EMYUO2KOGDM31QXT31SEV8JH116"
  29. plain_b = "IK0KEN0GEEN0ANDERE0LANDEN80ZELFS0AL0BEN0IK0ER0GEWEEST3"
  30.         # IK KEN GEEN ANDERE LANDEN, ZELFS AL BEN IK ER GEWEEST.
  31. code_opgave_c = "0ULW2BHR3SJALF5P2FWCYONLHPFW7YZN84UPQWNKMTYIEYTYN2QE63SJBLFV6SQE9Y27E2"
  32. code_opgave_d = "7RBNG4ACEK83YHUZLODARRHEZ3WT8URC4EC3XAQR448CW7NZK434K977B36D7ZEZRBU6PK" + \
  33.     "CCXDSUC4E6QXZ7FZRVYOCEJK3N8AOTEUR44O6Q6AJH4UZ4ONAB8RUEGHEAZPULMBO7RBIQ" + \
  34.     "UTKW78JJCWMKWOCSH6O73YONBV644CEDABR44CDYLR7HUUEC2XS6HIU7L03NBRLJ3CCUP"
  35. code_opgave_e = "808IXT5279C00PL9S1L4IXR6PR2CZF098JC8ECSIDQDW5KYB0ZU964ZICXHF" + \
  36.     "QDGKOQ2CXHP7HI9XE6KGAVEL0QLDIT IS HET BEGIN!L36HNIQXNMP1YFA"
  37.  
  38. # 14b
  39.  
  40. for s1_1 in range(1, 7, 1):
  41.     for s1_2 in range(s1_1 + 1, 7, 1):
  42.  
  43.         for s2_1 in range(s1_1 + 1, 7, 1):
  44.             if s2_1 in (s1_1, s1_2):
  45.                 continue
  46.             for s2_2 in range(s2_1 + 1, 7, 1):
  47.                 if s2_2 in (s1_1, s1_2):
  48.                     continue
  49.  
  50.                 for s3_1 in range(s2_1 + 1, 7, 1):
  51.                     if s3_1 in (s1_1, s1_2, s2_1, s2_2):
  52.                         continue
  53.  
  54.                     for s3_2 in range(s3_1 + 1, 7, 1):
  55.                         if s3_2 in (s1_1, s1_2, s2_1, s2_2):
  56.                             continue
  57.  
  58.                         steckers = [(s1_1, s1_2), (s2_1, s2_2), (s3_1, s3_2)]
  59.  
  60.                         key['steckers'] = steckers
  61.                         plain = cipher.decrypt(code_opgave_b, key)
  62.                         print(f"{key['steckers']} -> {plain}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement