Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #import FLAG from FLAGS
  2. #import SECRET_KEY from SECRET_KEYS
  3.  
  4. def encrypt(plane_text, secret_key):
  5. cipher_text = ""
  6. for pt, key in zip(plane_text, secret_key):
  7. cipher_num = ord(pt) ^ ord(key)
  8. cipher_text += format(cipher_num, '02x')
  9. return cipher_text
  10.  
  11. def padding(plane_text):
  12. pt_l = len(plane_text)
  13. if pt_l == 50:
  14. return plane_text
  15. else:
  16. plane_text += "%" * (50 - pt_l)
  17. return plane_text
  18.  
  19. def main():
  20. secret_key = SECRET_KEY
  21. plane_text = padding(FLAG)
  22. cipher_text = encrypt(plane_text, secret_key)
  23. with open("result.txt", 'a') as f:
  24. f.write("FLAG result: " + FLAG)
  25.  
  26. if __name__ == "__main__":
  27. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement