summaryrefslogtreecommitdiff
path: root/tests/encrypt_secret.py
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2017-10-19 11:03:10 -0700
committerClark Boylan <cboylan@sapwetik.org>2017-10-19 18:09:57 +0000
commit0996ab2857c69a436e9d7090bf266568f4f0730b (patch)
tree9560e8adf5a18d399f39a7b52beb05e366d07e77 /tests/encrypt_secret.py
parent9f0f4408d53bb09248201eebf7e09c5540b4f60c (diff)
downloadzuul-0996ab2857c69a436e9d7090bf266568f4f0730b.tar.gz
Make tests' encrypt_secret.py work with python3
This was not compatible with python3 due to encoding issues of the input and the out. Ensure we pass the input plaintext as bytes to the encryption routine and use the base64 module to convert the output to base64. Change-Id: Ie8b3a8e5c93544e448016829c1071240b68e8957
Diffstat (limited to 'tests/encrypt_secret.py')
-rw-r--r--tests/encrypt_secret.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/encrypt_secret.py b/tests/encrypt_secret.py
index 0b0cf19a1..4bc514ac2 100644
--- a/tests/encrypt_secret.py
+++ b/tests/encrypt_secret.py
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import base64
import sys
import os
@@ -27,8 +28,10 @@ def main():
private_key, public_key = \
encryption.deserialize_rsa_keypair(f.read())
- ciphertext = encryption.encrypt_pkcs1_oaep(sys.argv[1], public_key)
- print(ciphertext.encode('base64'))
+ plaintext = sys.argv[1].encode('utf-8')
+
+ ciphertext = encryption.encrypt_pkcs1_oaep(plaintext, public_key)
+ print(base64.b64encode(ciphertext).decode('utf-8'))
if __name__ == '__main__':