This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sqlite3 | |
| import random | |
| import os | |
| import base64 | |
| import uuid | |
| from typing import Tuple | |
| from fastapi import FastAPI, HTTPException | |
| from pydantic import BaseModel | |
| import io | |
| from cryptography.hazmat.primitives import hashes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class KeyManager: | |
| def __init__(self, db_name="demo_polynomial.db"): | |
| self.db_name = db_name | |
| self._create_tables() | |
| self.crypto_string = None | |
| self.crypto_csv = None | |
| self._initialize_demo_data() | |
| def _get_connection(self): | |
| return sqlite3.connect(self.db_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PolynomialMultiKeyEncryption: | |
| def __init__(self, raw_data: bytes = None): | |
| self.prime = 2**127 - 1 | |
| if raw_data: | |
| self.model_bytes = raw_data | |
| self.secret_value = random.randint(1000, 9999) | |
| self.coefficients = [self.secret_value] + [random.randint(1, self.prime-1) for _ in range(2)] | |
| self.salt = os.urandom(16) | |
| self.encryption_key = self._derive_encryption_key(self.secret_value) | |
| self.encrypted_data = self._encrypt_data() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sqlite3 | |
| import random | |
| import os | |
| import base64 | |
| import uuid | |
| from typing import Tuple | |
| from fastapi import FastAPI, HTTPException | |
| from pydantic import BaseModel | |
| import io | |
| from cryptography.hazmat.primitives import hashes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io | |
| import base64 | |
| import requests | |
| import onnxruntime as ort | |
| from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes | |
| from cryptography.hazmat.backends import default_backend | |
| SERVER_URL = "http://127.0.0.1:8000" | |
| def decrypt_data(encryptedModel, decryptKey) -> bytes: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import cv2 | |
| import numpy as np | |
| from util import detectionclassOV as net | |
| detection = net.Detection("./weights/compiled_detection.blob") | |
| def main(): | |
| frame = cv2.imread('./images/plate.jpg') | |
| image = frame.copy() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import cv2 | |
| import numpy as np | |
| from util import detectionclass as net | |
| detection = net.Detection('./weights/detection.onnx') | |
| def main(): | |
| frame = cv2.imread('./images/plate.jpg') | |
| image = frame.copy() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| import os | |
| import cv2 | |
| import numpy as np | |
| from pyclipper import * | |
| from shapely.geometry import Polygon | |
| class Detection: | |
| def __init__(self, onnx_path, session=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inflect | |
| librosa==0.9.2 | |
| matplotlib | |
| numpy | |
| Pillow | |
| PyQt5 | |
| scikit-learn | |
| scipy | |
| sounddevice | |
| SoundFile==0.10.3.post1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Crypto.Cipher import AES | |
| from Crypto.Random import get_random_bytes | |
| import base64 | |
| def encrypt_aes_gcm(plaintext, key): | |
| cipher = AES.new(key, AES.MODE_GCM) | |
| ciphertext, tag = cipher.encrypt_and_digest(plaintext) | |
| return ciphertext, cipher.nonce, tag | |
| # Example usage |
NewerOlder