Skip to content
Snippets Groups Projects

b64trans.py

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Eason Tse
    b64trans.py 397 B
    #!/usr/bin/env python3
    import argparse
    import base64
    
    parser = argparse.ArgumentParser()
    parser.add_argument("txt")
    args = parser.parse_args()
    
    
    def main():
        try:
            processed_str = base64.b64decode(args.txt)
        except base64.binascii.Error:
            processed_str = base64.b64encode(args.txt.encode("utf8"))
    
        print(processed_str.decode("utf8"))
    
    
    if __name__ == "__main__":
        main()
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment