Compare commits
No commits in common. "a2bdf2b1bf5492d88244158a0b07a8e1407f7288" and "319c7cac8caff1a44fae2bfba4937502e00a4da4" have entirely different histories.
a2bdf2b1bf
...
319c7cac8c
9 changed files with 14 additions and 49 deletions
|
@ -1,6 +1,6 @@
|
|||
# Sand
|
||||
|
||||
## Exécution avec Python 3.9.2
|
||||
## Exécution avec Python 3.10.8
|
||||
|
||||
Préparation de l'environnement
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ def init() -> None:
|
|||
|
||||
# Create upload folder if doesn't exists
|
||||
if not exist(Config.uploads_dir):
|
||||
mkdir(Config.uploads_dir)
|
||||
mkdir(path=Config.uploads_dir)
|
||||
|
||||
# TODO: Clear every t mins the uploads directory and database
|
||||
# TODO: On init, check if files in db are corresponding to the files stored
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
import { RSA_dec_data as RSA_dec } from "./rsa.js";
|
||||
|
||||
window.addEventListener("load", () => main());
|
||||
|
||||
const main = () => {
|
||||
const pub_key = window.location.hash.slice(1).split(":");
|
||||
const hash = window.location.pathname.split("/").pop();
|
||||
console.log(pub_key, hash);
|
||||
};
|
|
@ -88,7 +88,7 @@ const send = (file, element) => {
|
|||
let link = `${url.join("/")}/${req.responseText.slice(
|
||||
1,
|
||||
-2
|
||||
)}#${pub_key[0]}:${pub_key[1]}`;
|
||||
)}/${pub_key[0]}:${pub_key[1]}`;
|
||||
|
||||
let main_div = element.parentElement.parentElement;
|
||||
main_div.textContent = "";
|
|
@ -4,8 +4,10 @@ from flask import Blueprint, render_template
|
|||
router = Blueprint("file", __name__)
|
||||
|
||||
|
||||
@router.route("<int:file_hash>")
|
||||
def file(file_hash: int) -> str:
|
||||
@router.route("<int:file_hash>/<string:key_data>")
|
||||
def file(file_hash: int, key_data: str) -> str:
|
||||
"""Download page"""
|
||||
print(f"hash : {file_hash}")
|
||||
return render_template("download.html", config=Config)
|
||||
key = key_data.split(":")
|
||||
print(f"key : {key}")
|
||||
return render_template("index.html", config=Config, download=True)
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{{ config.name }}</title>
|
||||
|
||||
<link rel="stylesheet" href="../styles/style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header class="text-center">
|
||||
<h1 class="text-title">{{ config.name }}</h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="download-area">
|
||||
<h3>Téléchargement</h3>
|
||||
<p>Cliquez pour lancer le téléchargement du fichier</p>
|
||||
<button>Hihi</button>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>NPNO</p>
|
||||
</footer>
|
||||
|
||||
<script type="module" src="../js/download.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -30,6 +30,6 @@
|
|||
</footer>
|
||||
|
||||
<script src="https://unpkg.com/node-forge@1.0.0/dist/forge.min.js"></script>
|
||||
<script type="module" src="../js/index.js"></script>
|
||||
<script type="module" src="../js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from hashlib import sha256
|
||||
from sys import set_int_max_str_digits
|
||||
|
||||
BYTEORDER = "big"
|
||||
|
||||
|
@ -22,4 +23,6 @@ def int_to_bytes(data: int) -> bytes:
|
|||
|
||||
def hash_data(string: str) -> str:
|
||||
"""Hash a string"""
|
||||
# https://docs.python.org/3/library/sys.html#sys.set_int_max_str_digits
|
||||
set_int_max_str_digits(len(string))
|
||||
return str(int.from_bytes(sha256(int_to_bytes(int(string))).digest(), BYTEORDER))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from os import mkdir
|
||||
from sqlite3 import connect
|
||||
from sqlite3 import Cursor, connect
|
||||
|
||||
from utils.misc import exist
|
||||
|
||||
|
@ -17,7 +17,7 @@ class Database:
|
|||
|
||||
self.fullpath = fullpath
|
||||
|
||||
def request(self, request: str, valeurs=None) -> tuple:
|
||||
def request(self, request: str, valeurs=None) -> tuple[Cursor, int | None]:
|
||||
"""Send a request to the database"""
|
||||
connection = connect(self.fullpath)
|
||||
cursor = connection.cursor()
|
||||
|
|
Reference in a new issue