Skip to main content

Sample code

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:

  1. cert.pem  file

  2. key.pem file

  3. chain.pem file

  4. JPEG image to be signed (under 4MB).

  5. Python 3.10 or higher. (Python 3.11 is recommended)

  6. PIN

Run the script

  1. Go to the directory where the above items and python scripts are stored (including requirements.txt), run:

    cd ./folder_name 
  2. Create a virtual environment, run:

    python -m venv venv or python3.11 -m venv venv 
  3. Activate the virtual environment, run:

    source venv/bin/activate (mac/linux)      
    .\venv\Scripts\activate (Windows)      
    .\venv\Scripts\Activate.ps1 (Windows powershell)      
    .\venv\Scripts\activate.bat (Windows command prompt)  

    Your prompt will show (venv) to indicate that it is active.

  4. Install requirements.txt, run:

    pip install -r requirements.txt  

    An outdated pip causes installation errors. To upgrade it inside your virtual environment run:

    python -m pip install --upgrade pip
  5. To execute, run:

    python3.11 main.py <unsigned_image_path> <signed_image_path>    
    for ex- python3.11 main.py image.jpg signed_image.jpg