Make use of the bytes function that supports both py2 and 3 (#48904)

pull/48915/head
Tim Rupp 6 years ago committed by GitHub
parent 9b0dd5224b
commit 7546ebf08e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -199,6 +199,8 @@ shell:
import os import os
import tempfile import tempfile
from ansible.module_utils._text import to_bytes
try: try:
from BytesIO import BytesIO from BytesIO import BytesIO
except ImportError: except ImportError:
@ -870,11 +872,11 @@ class RootUserManager(BaseManager):
def encrypt_password_change_file(self, public_key, password): def encrypt_password_change_file(self, public_key, password):
# This function call requires that the public_key be expressed in bytes # This function call requires that the public_key be expressed in bytes
pub = serialization.load_pem_public_key( pub = serialization.load_pem_public_key(
bytes(public_key, 'utf-8'), to_bytes(public_key),
backend=default_backend() backend=default_backend()
) )
message = bytes("{0}\n{0}\n".format(password), 'utf-8') message = to_bytes("{0}\n{0}\n".format(password))
ciphertext = pub.encrypt( ciphertext = pub.encrypt(
message, message,

Loading…
Cancel
Save