forked from bstocker/EFREI_CryptoPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
87 lines (67 loc) · 2.64 KB
/
__init__.py
File metadata and controls
87 lines (67 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from cryptography.fernet import Fernet
from flask import Flask, render_template_string, render_template, jsonify
from flask import render_template
from flask import json
from flask import send_from_directory
from urllib.request import urlopen
import sqlite3
app = Flask(__name__)
@app.route('/')
def hello_world():
return render_template('hello.html')
key = Fernet.generate_key() #sss
f = Fernet(key)
@app.route('/encrypt/<string:valeur>')
def encryptage(valeur):
valeur_bytes = valeur.encode() # Conversion str -> bytes
token = f.encrypt(valeur_bytes) # Encrypt la valeur
return f"Valeur encryptée : {token.decode()}" # Retourne le token en str
@app.route('/decrypt/<string:token>')
def decryptage(token):
try:
token_bytes = token.encode() # Conversion str -> bytes
valeur = f.decrypt(token_bytes) # Décrypte le token
return f"Valeur décryptée : {valeur.decode()}" # Retourne la valeur en str
except Exception as e:
return f"Erreur de décryptage : {str(e)}"
if __name__ == "__main__":
app.run(debug=True)
@app.route('/Exercice1')
def ex1():
return render_template('exercice1.html')
@app.route('/Exercice2')
def ex2():
return render_template('exercice2.html')
@app.route('/Exercice3')
def ex3():
return render_template('exercice3.html')
@app.route('/Exercice4')
def ex4():
return render_template('exercice4.html')
@app.route('/sommaire')
def som():
return render_template('sommaire.html')
@app.route('/accueil')
def acu():
return render_template('accueil.html')
@app.route('/site')
def site():
return render_template('site.html')
@app.route('/maison')
def maison():
return render_template('maison.html')
@app.route('/baptiste')
def baptiste():
return render_template('baptiste.svg')
@app.route('/chenille')
def chenille():
return render_template('chenille.html')
@app.route('/dee')
def dée():
return render_template('Jeu_Des_Base.html')
@app.route('/outils')
def outils():
return render_template('Outils_JS.html')
@app.route('/roulette')
def roulette():
return render_template('Roulette_Russe_Etape_1_Barillet_Vide.html')