Working on Advanced Encryption Standard (AES), between agent backup and server.

This commit is contained in:
charlesgauthereau
2025-10-26 11:54:25 +01:00
parent 2a90d4933d
commit 7d6038e5f1
15 changed files with 200 additions and 22 deletions
+12 -7
View File
@@ -12,16 +12,21 @@ export async function GET(
const expires = searchParams.get('expires');
const fileName = (await params).fileName
const privateLocalDir = "private/uploads/files/";
const filePath = path.join(privateLocalDir, fileName);
console.log(token);
console.log(fileName);
const uploadsDir = "private/uploads/files/";
const keysDir = "private/keys/";
const uploadPath = path.join(uploadsDir, fileName);
const keyPath = path.join(keysDir, fileName);
const crypto = require('crypto');
if (!fs.existsSync(filePath)) {
return NextResponse.json(
{error: 'File not found'},
{status: 404}
);
let filePath = uploadPath;
if (!fs.existsSync(uploadPath)) {
if (fs.existsSync(keyPath)) filePath = keyPath;
else
return NextResponse.json({error: "File not found"}, {status: 404});
}
const expectedToken = crypto.createHash('sha256').update(`${fileName}${expires}`).digest('hex');