encryptare + adaugare de imagini
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import json
|
||||
import tkinter as tk
|
||||
|
||||
from app.http import request_builder
|
||||
from app.views.login import LoginView
|
||||
from app.views.initial import InitialView
|
||||
from app.views.signup import SignupView
|
||||
from app.views.main_page import MainPageView
|
||||
from app.encryption import AESEncryptor
|
||||
import json
|
||||
|
||||
|
||||
class MainApplication(tk.Tk):
|
||||
@@ -20,9 +24,21 @@ class MainApplication(tk.Tk):
|
||||
|
||||
self.current_logged_user = {}
|
||||
|
||||
self.define_http_params()
|
||||
self.encryptor = self.initialize_encryptor()
|
||||
|
||||
self.current_view = None
|
||||
self.change_to_initial_view()
|
||||
|
||||
def define_http_params(self):
|
||||
self.url = "http://localhost:8000/encryption/get_private_key"
|
||||
self.headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization_Key": "messenger"
|
||||
}
|
||||
self.method = "GET"
|
||||
self.params = None
|
||||
|
||||
def change_to_initial_view(self):
|
||||
self.change_view(InitialView(self))
|
||||
|
||||
@@ -51,3 +67,14 @@ class MainApplication(tk.Tk):
|
||||
self.current_logged_user['id'] = data['info']['id']
|
||||
self.current_logged_user['username'] = data['info']['username']
|
||||
self.current_logged_user['email'] = data['info']['email']
|
||||
|
||||
def initialize_encryptor(self):
|
||||
request_builder.set_url(self.url)
|
||||
request_builder.set_headers(self.headers)
|
||||
request_builder.set_method(self.method)
|
||||
|
||||
result = request_builder.build().make_request()
|
||||
json_data = json.loads(result.text)
|
||||
private_key = json_data.get("private_key", None)
|
||||
|
||||
return AESEncryptor(private_key)
|
||||
|
||||
Reference in New Issue
Block a user