SHARE
TWEET

Untitled

a guest Oct 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def decrypt(cipher_text, cipher_text2, message):
  2.     et = ""
  3.     for ct, ct2, m1 in zip(cipher_text, cipher_text2, message):
  4.         et_num = ct2 ^ ord(m1)
  5.         et_num ^= ct
  6.         et += chr(et_num)
  7.     return et
  8.  
  9. def padding(plane_text):
  10.     pt_l = len(plane_text)
  11.     if pt_l == 50:
  12.         return plane_text
  13.     else:
  14.         plane_text += "%" * (50 - pt_l)
  15.         return plane_text
  16.  
  17.  
  18. def main():
  19.     message = "I_may_lose_my_secret_key_before_long."
  20.     cipher = "140e1c3b020a0b1c3f28142e3001370e311f1b3e1a0d3a2b0610152d160a000d1d1c072b1d0b16001c033c2a2a26224e405c"
  21.     cipher2 = "1030183e1a3e0230180b301a262b1b003c020915310e3a0d3a1a1139181b1137031a1a385a4d407a5640465740517a4e405c"
  22.     ci_list = [cipher[i:i+2] for i in range(0, len(cipher), 2)]
  23.     ci_list = [int(ci_list[i], 16) for i in range(len(ci_list))]
  24.    
  25.     ci_list2 = [cipher2[i:i+2] for i in range(0, len(cipher2), 2)]
  26.     ci_list2 = [int(ci_list2[i], 16) for i in range(len(ci_list2))]
  27.    
  28.     message = padding(message)
  29.     flag = decrypt(ci_list, ci_list2, message)
  30.     print(flag)
  31.  
  32. if __name__ == "__main__":
  33.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top