This project is a Python script that scans a QR code containing a One-Time Password (OTP) for enhanced security. It utilizes the pyzbar
and PIL
libraries to decode the QR code image and extract the OTP.
To run this script, ensure that you have the following dependencies installed:
- Python 3
pyzbar
libraryPIL
librarypyotp
library
You can install the necessary libraries following this guide
-
Place the QR code image file (in PNG format) in the same directory as the script file.
-
Open a terminal or command prompt and navigate to the directory containing the script.
-
Run the script with the following command:
python3 get_otp.py <image_file_name_without_extension>
Replace
<image_file_name_without_extension>
with the actual name of your QR code image file (without the file extension). -
The script will decode the QR code image and print the extracted OTP to the console.
Suppose you have a QR code image file named otp_code.png
. To scan and retrieve the OTP, execute the following command:
python3 get_otp.py otp_code
The script will output the OTP to the console.
Please note that the QR code image file should be in PNG format and located in the same directory as the script file for successful execution.
To make it easier to run the script without typing the full command, you can create an alias. Here's how:
-
Place the python script and the QR code image in the same directory (e.g,
otp/
) -
Open your terminal's configuration file (e.g.,
~/.bashrc
for Bash) in a text editor. -
Add the following line at the end of the file:
alias otp="cd /path/to/otp/folder && python3 get_otp.py"
Replace
/path/to/otp/folder
with the actual path to theotp/
folder. -
Save the file and exit the text editor.
-
Reload the terminal configuration by running the following command:
source ~/.bashrc
Replace
~/.bashrc
with the path to your terminal's configuration file if it's different. -
You can now use the
otp
alias followed by the image file name to run the script. For example:otp otp_code
This will execute the script and output the OTP to the console.
This project is licensed under the MIT License. Feel free to modify and use it according to your needs.
- pyzbar library for QR code decoding.
- PIL library for image processing.
- pyotp library for OTP generation and validation.
This script is provided as-is without any warranty. Use it at your own risk.