Commit ec94cbe1 authored by Adrien Luxey's avatar Adrien Luxey
Browse files

hash instead of IP + user agent: no anonymisation of the dataset is needed here, now

parent 30b1f341
import os, json
import os, json, hashlib
from datetime import datetime
from secrets import token_hex
from flask import request, render_template, current_app, flash, redirect, url_for
......@@ -41,10 +41,13 @@ def save_results():
form = request.form.copy()
fn = os.path.join(
current_app.config['OUTPUT_DIR'], f"{form['guid']}.json")
sha1 = hashlib.sha1()
with open(fn, 'w') as f:
del form['guid']
del form['captcha']
form['date'] = datetime.utcnow().isoformat()
form['ip'] = get_remote_ip()
form['user_agent'] = request.user_agent.string
form['user_hash'] = sha1.hexdigest()
json.dump(form, f)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment