This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 74996bca92cd09f69357629ec664ec7873432836
Author: Greg Stein <[email protected]>
AuthorDate: Mon May 30 21:53:29 2022 -0500

    votestrings are for humans. use strings.
---
 v3/steve/crypto.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/v3/steve/crypto.py b/v3/steve/crypto.py
index 47943d3..9c7d33d 100644
--- a/v3/steve/crypto.py
+++ b/v3/steve/crypto.py
@@ -49,24 +49,24 @@ def gen_token(opened_key: bytes, value: str, salt: bytes) 
-> bytes:
 ### fix return type, to be a tuple
 def create_vote(voter_token: bytes,
                 issue_token: bytes,
-                votestring: bytes) -> bytes:
+                votestring: str) -> bytes:
     "Create a vote tuple, to record the VOTESTRING."
     salt = gen_salt()
     key = _hash(voter_token + issue_token, salt)
     b64key = base64.urlsafe_b64encode(key)
     f = cryptography.fernet.Fernet(b64key)
-    return salt, f.encrypt(votestring)
+    return salt, f.encrypt(votestring.encode())
 
 
 def decrypt_votestring(voter_token: bytes,
                        issue_token: bytes,
                        salt: bytes,
-                       token: bytes) -> bytes:
+                       token: bytes) -> str:
     "Decrypt TOKEN into a VOTESTRING."
     key = _hash(voter_token + issue_token, salt)
     b64key = base64.urlsafe_b64encode(key)
     f = cryptography.fernet.Fernet(b64key)
-    return f.decrypt(token)
+    return f.decrypt(token).decode()
 
 
 def _hash(data: bytes, salt: bytes) -> bytes:

Reply via email to