Package: totpy
TotpyDescriptionTotpy is CLI TOTP generator and management tool for Linux and MacOS. Can generate a TOTP token from a given secret key or from one stored in the configuration file. The secrets can be added to the configuration file using a secret key or the QR code image of a secret key. The default configuration file is stored in~/.local/config/totpy, but can be overriden with a given one.InstalationTotpy requires the follow packages:Click 7.0 (https://click.palletsprojects.com/en/7.x/)Pillow 7.0.0 (https://pillow.readthedocs.io/en/stable/)pypng 0.0.20 (https://pypng.readthedocs.io/en/latest/)PyQRCode 1.2.1 (https://pythonhosted.org/PyQRCode/)pyzbar 0.1.8 (https://github.com/NaturalHistoryMuseum/pyzbar/)pyperclip 1.7.0 ([https://github.com/asweigart/pyperclip])Totpy can be installed from this repository using pip:$ pip install git+https://github.com/jorgegarciadev/totpy.gitFrom the Python Package Index using pip:$ pip install totpyOr cloning this repository and running setup.py:$ git clone https://github.com/jorgegarciadev/totpy.git
$ python setup.py install --userin all cases It installs the module and the CLI tool.Usage-c --conf PATHOverrides the configuration stored in~/.local/config/totpy/config.jsonand uses the new file from now on. Checkconfig.examplefor more info.$ totpy -c conf.json foo-a --add NAMEAdds a new secret to the config file. The new secret can be added using a QR code image:$ totpy -a foo -q foo.pngOr passing directly the secret using the-soption:$ totpy -a foo -s JBSWY3DPEHPK3PXPIf the entry already exists it will be overwriten.-r --remove NAMERemoves the given entry from the configutarion file.$ totpy -r foo-qr NAMEGenerates a QR code for the given name and prints it in the terminal.$ totpy -qr foo-l --listShows all the entries' names in the configuration file.$ totpy -l-s --secretGenerates a TOTP token for the given secret key.$ totpy -s JBSWY3DPEHPK3PXP
235467--copyCopies the TOTP token to the clipboard.$ totpy --copy -s JBSWY3DPEHPK3PXP
235467

$ totpy --copy granada
099299NAMEGenerates a TOTP token using the secret stored in the configuration file for the given name.$ totpy granada
099299Totpy moduleTotpy includes three classes:Base: A helper class for managing the configuration file.Totpy: The class that defines thetotpyCLI tool behaviour.Totp: The class that generates the token.Totp classThis can be imported in your project and used. This is the source code:classTotp(object):"""docstring for Totpy"""def__init__(self,secret):self.secret=secretdefgetHotpToken(self,interval):key=base64.b32decode(self.secret,True)msg=struct.pack(">Q",int(time.time())//interval)h=hmac.new(key,msg,hashlib.sha1).digest()o=h[19]&15h=(struct.unpack(">I",h[o:o+4])[0]&0x7fffffff)%1000000returnhdefgetTotpToken(self):returnself.getHotpToken(interval=30)LicenseThis is free and open source software. You can use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of it, under the terms of the MIT License. See LICENSE.txt for details.This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or implied. See LICENSE.txt for details.SupportTo report bugs, suggest improvements, or ask questions, please create a new issue athttps://github.com/jorgegarciadev/totpy/issues.