summaryrefslogtreecommitdiff
path: root/rsa/cli.py
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2016-03-17 14:34:22 +0100
committerSybren A. Stüvel <sybren@stuvel.eu>2016-03-17 15:16:23 +0100
commitfedcaa1f94c637e5fe007f8799525d4bb13e66f9 (patch)
tree1d98ec645595a4e263d932cbe8ee8013bff08015 /rsa/cli.py
parent83a81107342ba414064703e5919978782d6bee01 (diff)
downloadrsa-git-fedcaa1f94c637e5fe007f8799525d4bb13e66f9.tar.gz
Ensuring that PEM output is always in bytes.
This may break some applications. However, it does make the RSA library easier to use on different Python versions.
Diffstat (limited to 'rsa/cli.py')
-rw-r--r--rsa/cli.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/rsa/cli.py b/rsa/cli.py
index 9415b97..fc01b12 100644
--- a/rsa/cli.py
+++ b/rsa/cli.py
@@ -83,6 +83,8 @@ def keygen():
outfile.write(data)
else:
print('Writing private key to stdout', file=sys.stderr)
+ if sys.version_info[0] >= 3:
+ data = data.decode('ascii') # on Py3 we must write text, not bytes
sys.stdout.write(data)
@@ -189,6 +191,8 @@ class CryptoOperation(object):
outfile.write(outdata)
else:
print('Writing output to stdout', file=sys.stderr)
+ if sys.version_info[0] >= 3:
+ data = outdata.decode('ascii') # on Py3 we must write text, not bytes
sys.stdout.write(outdata)