Skip to content

Commit

Permalink
feat: use Cryptography in _document module
Browse files Browse the repository at this point in the history
  • Loading branch information
jaedsonpys committed Feb 11, 2023
1 parent 94b8e9a commit b319915
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cookiedb/_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
# http://www.apache.org/licenses/LICENSE-2.0

import os
import pickle
from datetime import datetime
from typing import Union

import pickle
from cryptography import fernet

from . import exceptions
from ._encrypt import Cryptography


class Document:
def __init__(self, key: bytes, database_local: str) -> None:
self._fernet = fernet.Fernet(key)
self._crypt = Cryptography(key)
self._document_local = database_local
self._key = key.decode()

Expand All @@ -33,7 +32,7 @@ def exists_document(self, database: str) -> bool:

def _encrypt(self, obj: dict) -> str:
pickle_file = pickle.dumps(obj)
encrypted_data = self._fernet.encrypt(pickle_file)
encrypted_data = self._crypt.encrypt(pickle_file)
return encrypted_data

def _decrypt(self, encrypted: bytes) -> dict:
Expand Down

0 comments on commit b319915

Please sign in to comment.