b64-payload 561 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python3
  2. import base64
  3. import json
  4. import sys
  5. USAGE='''
  6. {0} --key1=file1 --key2=file2 ...
  7. '''
  8. def main(args):
  9. result = {}
  10. for key, filename in args.items():
  11. with open(filename, 'rb') as f:
  12. contents = f.read()
  13. result[key] = base64.b64encode(contents).decode('utf-8')
  14. json.dump(result, sys.stdout)
  15. if __name__ == '__main__':
  16. if '--help' in sys.argv[1:]:
  17. print(USAGE.format(sys.argv[0]))
  18. sys.exit(0)
  19. args = dict((arg.strip('--').split('=') for arg in sys.argv[1:]))
  20. main(args)