Advertisement
CSenshi

Cryptography - HW1.1 (Challenge-01)

Jan 10th, 2020
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. from base64 import b64encode
  2.  
  3.  
  4. def from_hex_to_base64(s):
  5.     # convert hex to string (bytes like object)
  6.     plain_text_bytes = bytes.fromhex(s)
  7.  
  8.     # convert from string to (bytes like object)
  9.     base64_bytes = b64encode(plain_text_bytes)
  10.  
  11.     # convet from base64 (bytes like object) to base64 (string)
  12.     base64_str = str(base64_bytes, "utf-8")
  13.  
  14.     # result
  15.     return base64_str
  16.  
  17.  
  18. if __name__ == "__main__":
  19.     s = input()
  20.     res = from_hex_to_base64(s)
  21.     print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement