From 0a7b0b7d4a6f007f65b9915cc9bee1e2593ebdc0 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 28 Oct 2022 15:02:28 +0200 Subject: [PATCH] keep list structure --- src/public/js/index.js | 4 ++-- src/routes/api/upload.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/public/js/index.js b/src/public/js/index.js index cf34cc2..7b068a7 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -70,8 +70,9 @@ const send = (file, element) => { gen_RSA_keypair(1024).then(([pub_key, sec_key]) => { element = update(element, "Chiffrement du fichier...", "H3"); + console.log(RSA_enc(content, sec_key)); let data = { - file: RSA_enc(content, sec_key).map((v) => v.toString()), + file: RSA_enc(content, sec_key).join(","), }; element = update(element, "Téléversement...", "H3"); @@ -109,7 +110,6 @@ const send = (file, element) => { input.readOnly = true; div.appendChild(input); - // TODO: Change button textContent on click let button = document.createElement("BUTTON"); button.textContent = "Copier le lien"; div.appendChild(button); diff --git a/src/routes/api/upload.py b/src/routes/api/upload.py index 121ae01..7eb6526 100644 --- a/src/routes/api/upload.py +++ b/src/routes/api/upload.py @@ -1,7 +1,7 @@ from time import time from config import Config -from flask import Blueprint, redirect, request, jsonify +from flask import Blueprint, jsonify, redirect, request from utils.misc import hash_data from werkzeug.wrappers.response import Response @@ -14,10 +14,11 @@ def upload() -> Response: json = request.get_json() if json: data = "".join(json["file"]) - data_hash = hash_data(data) + data_hash = hash_data(data.replace(",", "")) with open(f"{Config.uploads_dir}/{data_hash}", 'w') as f: f.write(data) + # Maybe add the encrypted filename ? Config.database.add_file(data_hash, int(time())) # Send the hash to the javascript client