mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Make use of the bytes function that supports both py2 and 3 (#48904)
This commit is contained in:
@@ -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,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user