-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy path__init__.py
More file actions
24 lines (19 loc) · 1.18 KB
/
__init__.py
File metadata and controls
24 lines (19 loc) · 1.18 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
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('hello.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)