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