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
44 lines (34 loc) · 1.72 KB
/
__init__.py
File metadata and controls
44 lines (34 loc) · 1.72 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
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 urllib.request import urlopen
import sqlite3
app = Flask(__name__)
@app.route('/')
def hello_world():
return render_template('jeu_de_des.html')
@app.route('/jack')
def exo_jack():
return render_template('jack.svg')
@app.route('/jeu_de_des_amelioration')
def exo_de():
return render_template('jeu_de_des_amelioration.html')
@app.route('/bibliotheque_images')
def exo_bibliotheque_images():
return render_template('bibliotheque_images.html')
@app.route('/roulette_russe')
def exo_roulette_russe():
return render_template('roulette_russe.html')
@app.route('/maxi_roulette_russe')
def exo_maxi_roulette_russe():
return render_template('maxi_roulette_russe.html')
key = Fernet.generate_key()
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
if __name__ == "__main__":
app.run(debug=True)