Skip to content

guard.py

Packages Used

Guard

Contains methods essential for security.

Guard.guard

Initialiser for Fernet().

Guard.encrypt(val)

Encodes and encrypts val according to Fernet key.

Parameters Returns
val: the object to encrypt binary: encrypted object

Guard.decrypt(val)

Decrypts and decodes val according to Fernet key.

Parameters Returns
val: the object to decrypt str: decrypted object

Guard.sha256(val)

Hashes val using SHA-256 algorithm with hashlib.

Parameters Returns
val: the object to hash str: hashed object

Guard.sanitized(request, key, val=None, db=None)

Verifies if a request is safe/sanitized.

Parameters Returns
request: the request made as a JSON
key: the element the request MUST have
val: the required corresponding value
db: instance of Database for more verification
bool: if sanitized