Skip to content

Commit

Permalink
Attempt to handle #10, add py3.8 to test config (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjfalling authored Feb 7, 2020
1 parent 7a526ee commit e9c4142
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ matrix:
- python: 3.5
- python: 3.6
- python: 3.7
- python: 3.8
dist: xenial
sudo: true

Expand Down
8 changes: 7 additions & 1 deletion totp_generator/core_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ def get_services(self):

def get_totp_code(self, service):
# force six digits
code = "%06d" % (onetimepass.get_totp(self.creds[service]['code']))
secret = self.creds[service]['code']
# this attempts to correct the padding when it is missing
# see https://github.com/tadeck/onetimepass/pull/22
mod = len(secret) % 8
if mod:
secret += '=' * (8 - mod)
code = "%06d" % (onetimepass.get_totp(secret))
return code

def import_creds_from_file(self, file_name):
Expand Down

0 comments on commit e9c4142

Please sign in to comment.