if regenerate_node_key:
# Generate 32 random bytes
- bytes = random.sample(range(0, 256), 32)
+ int8s = random.sample(range(0, 256), 32)
# Base64 encode their string representation
- node['key'] = base64.b64encode("".join(map(chr, bytes)))
+ node['key'] = base64.b64encode(bytes(int8s))
# XXX Boot Manager cannot handle = in the key
- node['key'] = node['key'].replace("=", "")
+ node['key'] = node['key'].replace(b"=", b"")
# Save it
node.sync()