diff options
| author | Simeon Simeonov | 2020-04-07 13:15:09 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2020-04-07 13:15:09 +0200 |
| commit | 719ad614ecb9e470fde7b54874a8da50df88519e (patch) | |
| tree | a93502147b07ee9feb44495fad3bd0a22dbe8e8b | |
| parent | 49b1c3e2cfb9b0224712e6891a12950f725c3b13 (diff) | |
Add __repr__ for OTPState and OTPGenerator
| -rw-r--r-- | otp2289/generator.py | 5 | ||||
| -rw-r--r-- | otp2289/server.py | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/otp2289/generator.py b/otp2289/generator.py index 4623dc0..723ed04 100644 --- a/otp2289/generator.py +++ b/otp2289/generator.py | |||
| @@ -333,6 +333,11 @@ class OTPGenerator: | |||
| 333 | 'Password must be longer than 10 bytes') | 333 | 'Password must be longer than 10 bytes') |
| 334 | self._password = password | 334 | self._password = password |
| 335 | 335 | ||
| 336 | def __repr__(self): | ||
| 337 | """repr implementation""" | ||
| 338 | return (f'{self.__class__} at {id(self)} (seed={self._seed}, ' | ||
| 339 | f'hash_algo={self._hash_algo})') | ||
| 340 | |||
| 336 | @staticmethod | 341 | @staticmethod |
| 337 | def bit_pair_sum(bit_stream): | 342 | def bit_pair_sum(bit_stream): |
| 338 | """ | 343 | """ |
diff --git a/otp2289/server.py b/otp2289/server.py index 119fbff..7322727 100644 --- a/otp2289/server.py +++ b/otp2289/server.py | |||
| @@ -85,6 +85,13 @@ class OTPState: | |||
| 85 | self._current_digest = self.validate_hex(ot_hex) | 85 | self._current_digest = self.validate_hex(ot_hex) |
| 86 | self._new_digest_hex = None # set upon a successful validation | 86 | self._new_digest_hex = None # set upon a successful validation |
| 87 | 87 | ||
| 88 | def __repr__(self): | ||
| 89 | """repr implementation""" | ||
| 90 | return (f'{self.__class__} at {id(self)} ' | ||
| 91 | f'(ot_hex={self._current_digest}, current_step={self._step}, ' | ||
| 92 | f'seed={self._seed}, ' | ||
| 93 | f'hash_algo={self._hash_algo})') | ||
| 94 | |||
| 88 | @property | 95 | @property |
| 89 | def challenge_string(self): | 96 | def challenge_string(self): |
| 90 | """challenge_string-property""" | 97 | """challenge_string-property""" |
