From e23ec5d1dd40b9d3a3b7b0bd53f22fd187488ab0 Mon Sep 17 00:00:00 2001 From: CooperRS Date: Thu, 15 Feb 2018 21:43:29 +0100 Subject: [PATCH] Fix algorithm parameter --- decrypt_otpauth.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/decrypt_otpauth.py b/decrypt_otpauth.py index 8598948..24be97c 100644 --- a/decrypt_otpauth.py +++ b/decrypt_otpauth.py @@ -39,6 +39,19 @@ class Algorithm(Enum): SHA512 = 3 MD5 = 4 + @property + def uri_value(self): + if self.value == 0: + return 'sha1' + if self.value == 1: + return 'sha1' + if self.value == 2: + return 'sha256' + if self.value == 3: + return 'sha512' + if self.value == 4: + return 'md5' + class MutableString: @@ -123,7 +136,7 @@ class OTPAccount: otp_label = quote(f'{self.issuer}:{self.label}') otp_parameters = { 'secret': base64.b32encode(self.secret).decode("utf-8").rstrip("="), - 'algorithm': self.algorithm, + 'algorithm': self.algorithm.uri_value, 'period': self.period, 'digits': self.digits, 'issuer': self.issuer,