Skip to content
Snippets Groups Projects
Commit 45c66b6d authored by Christian Boettcher's avatar Christian Boettcher
Browse files

proper de- and encoding

parent ded9f494
No related branches found
No related tags found
No related merge requests found
from fastapi.exceptions import HTTPException from fastapi.exceptions import HTTPException
from JsonFileStorageAdapter import JsonFileStorageAdapter, LocationDataType from .JsonFileStorageAdapter import JsonFileStorageAdapter, LocationDataType
from cryptography.fernet import Fernet from cryptography.fernet import Fernet
from apiserver.config.settings import ApiserverSettings from apiserver.config.settings import ApiserverSettings
...@@ -8,11 +8,11 @@ class EncryptedJsonFileStorageAdapter(JsonFileStorageAdapter): ...@@ -8,11 +8,11 @@ class EncryptedJsonFileStorageAdapter(JsonFileStorageAdapter):
def encrypt(self, string: str): def encrypt(self, string: str):
f = Fernet(self.encryption_key) f = Fernet(self.encryption_key)
return f.encrypt(string.encode()) return f.encrypt(string.encode()).decode("utf-8")
def decrypt(self, string: str): def decrypt(self, string: str):
f = Fernet(self.encryption_key) f = Fernet(self.encryption_key)
return f.decrypt(string.encode()) return f.decrypt(string.encode()).decode("utf-8")
def __init__(self, settings: ApiserverSettings, encryption_key) -> None: def __init__(self, settings: ApiserverSettings, encryption_key) -> None:
self.encryption_key = encryption_key self.encryption_key = encryption_key
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment