mirror of
https://github.com/scito/extract_otp_secret_keys.git
synced 2025-12-06 14:54:57 +01:00
minor improvements
This commit is contained in:
parent
cc26f7b589
commit
fb66c5f568
2 changed files with 7 additions and 7 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
qr/
|
||||
|
|
@ -72,12 +72,11 @@ def get_enum_name_by_number(parent, field_name):
|
|||
def convert_secret_from_bytes_to_base32_str(bytes):
|
||||
return str(base64.b32encode(otp.secret), 'utf-8').replace('=', '')
|
||||
|
||||
|
||||
def save_qr(data, name):
|
||||
qr = QRCode()
|
||||
qr.add_data(data)
|
||||
img = qr.make_image(fill_color="black", back_color="white")
|
||||
if verbose: print("Saving to {}".format(name))
|
||||
img = qr.make_image(fill_color='black', back_color='white')
|
||||
if verbose: print('Saving to {}'.format(name))
|
||||
img.save(name)
|
||||
|
||||
def print_qr(data):
|
||||
|
|
@ -111,12 +110,12 @@ for line in (line.strip() for line in fileinput.input(args.infile)):
|
|||
otp_url = 'otpauth://{}/{}?'.format('totp' if otp.type == 2 else 'hotp', quote(otp.name)) + urlencode(url_params)
|
||||
if saveqr:
|
||||
if verbose: print(otp_url)
|
||||
if not(path.exists("qr")): mkdir("qr")
|
||||
pattern = rcompile('[\W_]+')
|
||||
if not(path.exists('qr')): mkdir('qr')
|
||||
pattern = rcompile(r'[\W_]+')
|
||||
file_otp_name = pattern.sub('', otp.name)
|
||||
file_otp_issuer = pattern.sub('', otp.issuer)
|
||||
if not(file_otp_issuer): print_qr(otp_url, "qr/{}-{}.png".format(i, file_otp_name))
|
||||
if file_otp_issuer: save_qr(otp_url, "qr/{}-{}-{}.png".format(i,file_otp_name, file_otp_issuer))
|
||||
if not(file_otp_issuer): print_qr(otp_url)
|
||||
if file_otp_issuer: save_qr(otp_url, 'qr/{}-{}-{}.png'.format(i, file_otp_name, file_otp_issuer))
|
||||
if printqr:
|
||||
if verbose: print(otp_url)
|
||||
print_qr(otp_url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue