From 61bab4177582435ca16962015182020da00bf596 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 24 Apr 2013 08:36:25 +0000 Subject: Support using base32 keys git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@621 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- oath-qr | 9 +++++++-- 1 file 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 -- cgit v1.2.3