Created
March 5, 2022 10:37
-
-
Save swanav/5c824dc3b32fa97379c216e99e73a3e2 to your computer and use it in GitHub Desktop.
Create a base64 string for a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import base64 | |
def main(args): | |
file_content = None | |
with open(args.input, 'rb') as f: | |
file_content = f.read() | |
b64_content = base64.b64encode(file_content) | |
with open(args.output, 'w') as f: | |
f.write(b64_content.decode('utf-8')) | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-i', '--input', required=True, help='Input file') | |
parser.add_argument('-o', '--output', required=True, help='Output file') | |
main(parser.parse_args()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment