From 3c24c1aa82584b7e88898f2e31f4c3a38c43bc5d Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 21 Oct 2019 18:26:39 +0100 Subject: [PATCH] catacomb/pwsafe.py: Use `binascii' for Base64 conversion. The `.encode()' and `.decode()' string methods were apparently too convenient, so Python 3 doesn't do Base64 conversion like this. Instead, we have to use the steam-powered `binascii'. And, to make things even better, encoding produces `bytes' rather than `str' because, err, it's not really text or something? No idea. Stoats. --- catacomb/pwsafe.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/catacomb/pwsafe.py b/catacomb/pwsafe.py index d453c8e..8fa5ee6 100644 --- a/catacomb/pwsafe.py +++ b/catacomb/pwsafe.py @@ -28,6 +28,7 @@ from __future__ import with_statement +import binascii as _B import errno as _E import os as _OS from cStringIO import StringIO as _StringIO @@ -103,10 +104,10 @@ def _dec_metaname(name): def _b64(s): """Encode S as base64, without newlines, and trimming `=' padding.""" - return s.encode('base64').replace('\n', '').rstrip('=') + return _text(_B.b2a_base64(s)).replace('\n', '').rstrip('=') def _unb64(s): """Decode S as base64 with trimmed `=' padding.""" - return (s + '='*((4 - len(s))%4)).decode('base64') + return _B.a2b_base64(s + '='*((4 - len(s))%4)) def _enc_metaval(val): """Encode VAL as a metadata item value, returning the result.""" -- 2.11.0