Skip to content
This repository was archived by the owner on Sep 5, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/jetson/AES.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

class Encryption():

def __init__(self):
def __init__(self, passwd):
'''
This class handles encryption to prevent identifiable information (facial data)
from leaving the camera. It also generates a random key that will be used by
authorized personnel to acces the data.
'''
self.salt = os.urandom(16) #Salt variable (Generates a random byte string)
self.key = PBKDF2("passphrase", self.salt).read(16) #Creates key using KDF scheme
self.salt = "Embedded2"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need to save this as a variable? its only used in the constructor

self.key = PBKDF2(passwd, self.salt).read(16) #Creates key using KDF scheme

def encrypt(self,
coordinates: List[Tuple[int]],
Expand Down
4 changes: 2 additions & 2 deletions src/jetson/encryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from typing import List, Tuple

class Encryptor(object):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this class is backwards. Why do we need to re-encapsulate AESEncryptor with Encryptor? I think it would be much better for AESEncryptor to make all encryptors just implement encryptFace and encryptFrame themselves. This will then resolve the weird import statement from src.jetson.AES import Encryption as AESEncryptor which is very misleading.

def __init__(self):
def __init__(self, passwd):
"""
This class acts as a wrapper for the AES encryptor in AES.py and stores the encryption key for decrypting
"""
self.encryptor = AESEncryptor()
self.encryptor = AESEncryptor(passwd)
self.key = self.encryptor.key

def encryptFace(self, coordinates: List[Tuple[int]],
Expand Down
6 changes: 5 additions & 1 deletion src/jetson/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import warnings
import json
import getpass
from multiprocessing import Process, Queue, Value

import cv2
Expand Down Expand Up @@ -122,7 +123,10 @@ def drawFrame(boxes, frame, fps):
detector = FaceDetector(detector=detector, detector_type=detector_type,
cuda=cuda and torch.cuda.is_available(), set_default_dev=True)
classifier = Classifier(classifier_model, cuda)
encryptor = Encryptor()

passwd = getpass.getpass("Enter password to use for image encryption:")
encryptor = Encryptor(passwd)
del passwd

run_face_detection: bool = True
while run_face_detection: # main video detection loop that will iterate until ESC key is entered
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup(self):
self.img = np.zeros((300,300,3),np.uint8)
self.img[:] = (0, 0, 255)
self.output_dir = "test_output"
self.encryptor = Encryptor()
self.encryptor = Encryptor("frog")
self.boxes = [(10, 10, 20, 20)]

def test_writeImg(self):
Expand Down