summaryrefslogtreecommitdiff
path: root/oath-qr
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2013-04-24 08:36:25 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2013-04-24 08:36:25 +0000
commit61bab4177582435ca16962015182020da00bf596 (patch)
tree7f55159eb3c456c287bda9a226c0fc3f981e2966 /oath-qr
parenta2d68563fd9f7dac29e0a7b47f9b94a83f43b2db (diff)
Support using base32 keys
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@621 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
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