Sample code
less than a minute
Before you run the example files, ensure that the following prerequisites are stored in the same place as requirements.txt, main.py and dtmCSC.py files:
- cert.pem file
- key.pem file
- chain.pem file
- JPEG image to be signed (under 4MB).
- Python 3.10 or higher. (Python 3.11 is recommended)
- PIN
Note
This sample code works with a file named road.jpg and returns signed image named signed_road.jpg.Run the script
- Go to the directory where the above items and python scripts are stored (including requirements.txt), run:
cd ./folder_name - Create a virtual environment, run:
python3.11 -m venv venv - Activate the virtual environment, run:
Your prompt will show (venv) to indicate that it is active.source venv/bin/activate (mac/linux) .\venv\Scripts\activate (Windows) .\venv\Scripts\Activate.ps1 (Windows powershell) .\venv\Scripts\activate.bat (Windows command prompt) - Install requirements.txt, run:
An outdated pip causes installation errors. To upgrade it inside your virtual environment run:pip install -r requirements.txtpython3.11 -m pip install --upgrade pip - To execute, run:
python3.11 main.py <unsigned_image_path> <signed_image_path> for ex- python3.11 main.py image.jpg signed_image.jpg
Was this page helpful?
Provide feedback