qure 0.3
A Python package to generate Student Cards with unique Qrcode from CSV or JSON
Requires Python: >=3.6

# Qure: QR Code Generator and Scanner Library

## Overview
This library provides an easy-to-use API for generating and scanning QR codes and Student Cards with data encryption. The library can read JSON and CSV input files, allowing flexibility in the types of data processed. QR codes generated by this library are encrypted using the cryptography package, ensuring data security.

### The library features:

Data Encryption: Encrypts data before encoding it into a QR code for added security.
Flexible Data Input: Accepts data in JSON or CSV format.
Automatic QR Code Generation: Generates QR codes from student information or other data sets.
QR Code Scanning: Supports reading and decrypting encrypted data from QR codes.
Prerequisites
To use this library, ensure you have:

Python 3.6+ installed.
The necessary dependencies listed in requirements.txt.

## Installation
Clone the Repository

```bash
git clone https://github.com/fraterneelyh/qure.git
cd qure

```
Install Dependencies Install the required dependencies using requirements.txt:


``` bash
pip install -r requirements.txt
```
Alternatively, you can install directly using:

``` bash
pip install qrcode[pil] Pillow pyzbar cryptography
```
Folder Structure Ensure the qrcodes directory exists or is created at runtime if saving QR codes in this folder.

## Usage
1. Generate a Single QR Code with JSON Data
To generate a QR code for a single record in JSON format:

```python
from qure.generation.generator import QRGenerator

# Define data
data = {
    "name": "Alice Johnson",
    "age": 25,
    "email": "alice@example.com",
    "photo": "path/to/student_image"
}

# Create QRGenerator instance and generate QR code
qr_generator = QRGenerator(data)
file_path = qr_generator.generate()
print(f"QR code saved to: {file_path}")
```
2. Generate Multiple QR Codes from a JSON File
To generate multiple QR codes from a JSON file with a list of students:

``` python
from qure.generation.generator import generate_multiple_qrcodes

# Provide JSON file path
json_file_path = "path/to/your/students.json"
generate_multiple_qrcodes(json_file_path)
```

Example JSON Structure

```json
{
    "students": [
        {"name": "Alice", "age": 22, "email": "alice@example.com", "photo": "path/to/student/photo"},
        {"name": "Bob", "age": 23, "email": "bob@example.com", "photo": "path/to/student/photo"}
    ]
}
```
3. Generate QR Codes from CSV Data
This library also allows QR code generation from CSV data:

```python
Copy code
from qure.generation.generator import generate_multiple_qrcodes_from_csv

csv_file_path = "path/to/your/students.csv"
generate_multiple_qrcodes_from_csv(csv_file_path)
```
Example CSV Structure

``` csv
name,age,email
Alice,22,alice@example.com
Bob,23,bob@example.com
```

4. Scanning and Decrypting QR Codes
To scan and decrypt an encrypted QR code:

``` python
from qure.scanner.scanner import QRScanner

# Provide the path to the QR code image
qr_scanner = QRScanner("path/to/your/qrcode.png")
decrypted_data = qr_scanner.scan()
print("Decrypted data:", decrypted_data)
```

## Configuration

Encryption Key: The library automatically uses a generated key for encryption and decryption. If you need to set a custom key, modify the key in qure/encryption.py.

Output Folder: Ensure the qrcodes folder exists for saving QR codes. Use the following code to create the folder if it doesn't exist:
```python
Copy code
import os
os.makedirs("qrcodes", exist_ok=True)
```
## Dependencies

i. qrcode[pil] - For creating QR codes.

ii. Pillow - For handling image file operations.

iii. pyzbar - For decoding QR codes.

iv. cryptography - For encrypting and decrypting data in QR codes.

These dependencies are listed in requirements.txt.

## Testing
This library includes tests to verify its functionality. You can run tests with:

```bash
Copy code
python -m unittest discover tests
```
## Contributing
### Contributions are welcome! Please follow these steps:

Fork the repository and clone it locally.

Create a new branch for your feature or bugfix.

Make your changes and update tests if necessary.

Run tests to ensure no new issues are introduced.

Submit a pull request, describing your changes.

## License
This project is licensed under the MIT License. See the LICENSE file for more details.

## Contact

For questions or further assistance, please reach out to HOZANA INEZA Fraterne Ely at [fraterneelyh@gmail.com].