From c2c2eda52e816a9bf35d830552294d11bc72ad77 Mon Sep 17 00:00:00 2001 From: meejah Date: Mon, 8 Jul 2019 14:16:28 -0600 Subject: [PATCH] bytes --- src/allmydata/crypto/util.py | 10 +++++----- src/allmydata/util/fileutil.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/allmydata/crypto/util.py b/src/allmydata/crypto/util.py index 7e4ebb92f..6aa1f0973 100644 --- a/src/allmydata/crypto/util.py +++ b/src/allmydata/crypto/util.py @@ -17,8 +17,8 @@ def remove_prefix(s_bytes, prefix): :returns: `s_bytes` with `prefix` removed from the front. """ - if not s_bytes.startswith(prefix): - raise BadPrefixError( - "did not see expected '{}' prefix".format(prefix) - ) - return s_bytes[len(prefix):] + if s_bytes.startswith(prefix): + return s_bytes[len(prefix):] + raise BadPrefixError( + "did not see expected '{}' prefix".format(prefix) + ) diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py index 66dd26817..162852c38 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -111,7 +111,7 @@ class EncryptedTemporaryFile(object): iv = binascii.unhexlify("%032x" % offset_big) cipher = aes.create_encryptor(self.key, iv) # this is just to advance the counter - aes.encrypt_data(cipher, "\x00" * offset_small) + aes.encrypt_data(cipher, b"\x00" * offset_small) return aes.encrypt_data(cipher, data) def close(self):