From 7546ebf08eaf2b3417bc7188a83069cd217a042a Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Mon, 19 Nov 2018 15:24:31 -0800 Subject: [PATCH] Make use of the bytes function that supports both py2 and 3 (#48904) --- lib/ansible/modules/network/f5/bigip_user.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/f5/bigip_user.py b/lib/ansible/modules/network/f5/bigip_user.py index 0c08d0605c..625b829eab 100644 --- a/lib/ansible/modules/network/f5/bigip_user.py +++ b/lib/ansible/modules/network/f5/bigip_user.py @@ -199,6 +199,8 @@ shell: import os import tempfile +from ansible.module_utils._text import to_bytes + try: from BytesIO import BytesIO except ImportError: @@ -870,11 +872,11 @@ class RootUserManager(BaseManager): def encrypt_password_change_file(self, public_key, password): # This function call requires that the public_key be expressed in bytes pub = serialization.load_pem_public_key( - bytes(public_key, 'utf-8'), + to_bytes(public_key), 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( message,