summaryrefslogtreecommitdiff
path: root/oath-qr
diff options
context:
space:
mode:
Diffstat (limited to 'oath-qr')
-rwxr-xr-xoath-qr9
1 files changed, 7 insertions, 2 deletions
diff --git a/oath-qr b/oath-qr
index 5ab08c5..2abd1b1 100755
--- a/oath-qr
+++ b/oath-qr
@@ -33,6 +33,8 @@ parser.add_option("-r", "--raw", dest="raw", default=False, action="store_true",
help="Encode just the base32 key, not an otpauth:// URL.")
parser.add_option("-n", "--name", dest="name",
help="Provide a name for this otpauth token.")
+parser.add_option("-b", "--base32", dest="base32", default=False, action="store_true",
+ help="Key already is in base32.")
(options, args) = parser.parse_args()
if len(args) >= 2:
@@ -44,8 +46,11 @@ else:
print "Enter key: ",
hexkey = sys.stdin.readline().rstrip()
-binkey = base64.b16decode(hexkey, True)
-b32key = base64.b32encode(binkey)
+if options.base32:
+ b32key = hexkey
+else:
+ binkey = base64.b16decode(hexkey, True)
+ b32key = base64.b32encode(binkey)
if options.raw:
msg = b32key