You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
978 B
Python
47 lines
978 B
Python
11 years ago
|
#!/usr/bin/env python
|
||
|
# -*- coding: utf-8 -*-
|
||
12 years ago
|
|
||
11 years ago
|
# base64.py, version 1.0
|
||
|
# Copyright © 2010 Apprentice Alf
|
||
12 years ago
|
|
||
11 years ago
|
# Released under the terms of the GNU General Public Licence, version 3 or
|
||
|
# later. <http://www.gnu.org/licenses/>
|
||
12 years ago
|
|
||
11 years ago
|
# Revision history:
|
||
|
# 1 - Initial release. To allow Applescript to do base64 encoding
|
||
12 years ago
|
|
||
11 years ago
|
"""
|
||
|
Provide base64 encoding.
|
||
|
"""
|
||
12 years ago
|
|
||
11 years ago
|
from __future__ import with_statement
|
||
5 years ago
|
from __future__ import print_function
|
||
12 years ago
|
|
||
11 years ago
|
__license__ = 'GPL v3'
|
||
12 years ago
|
|
||
11 years ago
|
import sys
|
||
|
import os
|
||
|
import base64
|
||
12 years ago
|
|
||
11 years ago
|
def usage(progname):
|
||
5 years ago
|
print("Applies base64 encoding to the supplied file, sending to standard output")
|
||
|
print("Usage:")
|
||
|
print(" %s <infile>" % progname)
|
||
12 years ago
|
|
||
11 years ago
|
def cli_main(argv=sys.argv):
|
||
|
progname = os.path.basename(argv[0])
|
||
12 years ago
|
|
||
11 years ago
|
if len(argv)<2:
|
||
|
usage(progname)
|
||
|
sys.exit(2)
|
||
12 years ago
|
|
||
11 years ago
|
keypath = argv[1]
|
||
|
with open(keypath, 'rb') as f:
|
||
|
keyder = f.read()
|
||
5 years ago
|
print(keyder.encode('base64'))
|
||
12 years ago
|
return 0
|
||
12 years ago
|
|
||
11 years ago
|
|
||
|
if __name__ == '__main__':
|
||
|
sys.exit(cli_main())
|