Commit e8a3d3d9 authored by ale's avatar ale

Improve Python3 compatibility

parent cc5ef01e
......@@ -70,7 +70,7 @@ def generate_simple_password(length=32):
The resulting passwords should be alphanumeric, easily
cut&pastable and usable on the command line.
"""
n = length * 5 / 8
n = int(length * 5 / 8)
return base64.b32encode(os.urandom(n)).rstrip('=')
......@@ -83,7 +83,7 @@ def generate_binary_secret(length=32):
base64-encode them instead.
"""
n = length * 3 / 4
n = int(length * 3 / 4)
return base64.b64encode(os.urandom(n)).rstrip('=')
......@@ -120,9 +120,9 @@ def generate_tsig_key():
def generate_password(entry):
ptype = entry.get('type', 'simple')
if ptype == 'simple':
return generate_simple_password(length=entry.get('length', 32))
return generate_simple_password(length=int(entry.get('length', 32)))
elif ptype == 'binary':
return generate_binary_secret(length=entry.get('length', 32))
return generate_binary_secret(length=int(entry.get('length', 32)))
elif ptype == 'tsig':
return generate_tsig_key()
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment