diff options
-rwxr-xr-x | oath-qr | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 |