A Python script that generates QR codes containing authentication data (URL and secret key) and displays them both in the terminal and as image files.
- Generates QR codes with authentication data (URL and secret key)
- Displays QR code directly in the terminal
- Saves QR code as PNG image file
- Uses functional programming principles
- Python 3.6+
qrcodelibraryqrcode-terminallibrary
- Clone this repository:
git clone https://github.com/Egregore-ai/generate-qr-code
cd generate-qr-code- Install required packages:
pip install qrcode qrcode-terminalRun the script directly:
python main.pyThe script will:
- Generate a random secret key
- Create a JSON payload with the URL and secret key
- Display the QR code in the terminal
- Save the QR code as
auth_qr.pngin the current directory
You can modify the url and secret_key values in the if __name__ == "__main__": block to customize the authentication data.
The script provides several functions for generating QR codes:
create_auth_qr_data(url, secret_key): Creates a JSON payload containing the URL and secret keygenerate_qr_code(data): Generates a QR code (as PNG bytes) from input string dataqr_pipeline(url, secret_key): End-to-end pipeline that returns both JSON payload and QR image bytes