Skip to content
Snippets Groups Projects
public
Authored by avatar Eason Tse @eason.tse

b64trans.py

Embed
Share
  • Clone with SSH
  • Clone with HTTPS
  • 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% or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment