Skip to content

Commit

Permalink
import-qr initial
Browse files Browse the repository at this point in the history
  • Loading branch information
karakays committed Apr 4, 2021
1 parent b6d380e commit e7582b4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@ ENV/

# mypy
.mypy_cache/

.idea/
11 changes: 10 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
* in case of missing configuration, stacktrace is dumped
* sha-256 specified in config but sha-1 is in code


## IMPROVE
* versioning
* remove QR code functionality
* improve docs (with zero dependency)

otp # show token from current profile
otp --import-file
otp --import # config
otp --profiles
otp --delete-profile
otp --use-profile

## FEATURE
* better user experience
Expand All @@ -21,6 +26,10 @@
- otp rm <id>
* hotp support

* decode qr code
https://betterprogramming.pub/how-to-generate-and-decode-qr-codes-in-python-a933bce56fd0

* bash auto-complete

## TODO
* release 0.2.0!
8 changes: 8 additions & 0 deletions otp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import time
import base64
import binascii
import cv2 as cv
from urllib.parse import parse_qs, urlunsplit, urlencode
from otp import qr_code
from otp.token import Token, TokenType, InvalidTokenUriError
Expand Down Expand Up @@ -55,6 +56,13 @@ def get_otp_by_uri(uri):
return get_otp_by_secret(secret, **kwargs)


def get_otp_by_qrcode(file):
im = cv.imread(file)
det = cv.QRCodeDetector()
retval, points, straight_qrcode = det.detectAndDecode(im)
return get_otp_by_uri(retval)


def get_otp_by_secret(secret, **kwargs):
if not secret:
raise InvalidTokenUriError('Secret cannot be null')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
maintainer='Selçuk Karakayalı',
url='http://github.com/karakays/otp-py/',
packages=find_packages(),
install_requires=['pyqrcode>=1.2.1'],
install_requires=['pyqrcode>=1.2.1', 'cv2'],
python_requires='>=3.6',
license='MIT',
keywords=['otp', 'otp-codes', 'otp-generator', 'authenticator'],
Expand Down

0 comments on commit e7582b4

Please sign in to comment.