P2 finito tout marche
This commit is contained in:
parent
f5be203305
commit
9e2fd37838
15 changed files with 238 additions and 143 deletions
|
@ -2,24 +2,26 @@ from flask import *
|
|||
import ssl
|
||||
import requests
|
||||
import rsa
|
||||
import urllib3
|
||||
|
||||
data = 'Hello World !'
|
||||
with open("ssl/server_public.pem","r") as f_public:
|
||||
pubi_k = rsa.PublicKey.load_pkcs1(f_public.read())
|
||||
|
||||
with open("../server/ssl/public.key", "rb") as public_serv_file:
|
||||
public_serv = public_serv_file.read()
|
||||
message = "Hello World !".encode()
|
||||
encrypt_message= rsa.encrypt(message,pubi_k)
|
||||
|
||||
with open("ssl/id_rsa", "rb") as private_key_file:
|
||||
private_key = private_key_file.read()
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
response = requests.post('https://localhost:5000/data',data=encrypt_message, verify="ssl/CA.crt")
|
||||
|
||||
public_key_serv = rsa.PublicKey.load_pkcs1(public_serv)
|
||||
private_key_client = rsa.PrivateKey.load_pkcs1(private_key)
|
||||
print(response.json())
|
||||
|
||||
'''
|
||||
Generation clef
|
||||
(public_key, private_key) = rsa.newkeys(4096)
|
||||
|
||||
crypt = rsa.encrypt(data.encode(), public_key_serv)
|
||||
with open("ssl/public.pem", "wb") as pub_file:
|
||||
pub_file.write(public_key.save_pkcs1("PEM"))
|
||||
|
||||
# Afficher le message original (pour vérification)
|
||||
print(data)
|
||||
|
||||
response = requests.post('https://localhost:5000', data={'message': crypt, 'signature': signature}, verify=False)
|
||||
|
||||
#print(response.text)
|
||||
with open("ssl/private.pem", "wb") as priv_file:
|
||||
priv_file.write(private_key.save_pkcs1("PEM"))
|
||||
'''
|
Loading…
Add table
Add a link
Reference in a new issue