Implemented feature that allows users to delete passwords if needed.

This commit is contained in:
Afonso Clerigo Mendes de Sousa 2025-02-27 21:10:50 +00:00
parent e282ff5f7f
commit a0347a7ca4
2 changed files with 23 additions and 1 deletions

View File

@ -42,7 +42,7 @@
*/ */
#define add(ptr, index, value) ptr[index] = value //@param ptr Pointer to add the value @param index Index of the value to add @param value Value to add #define add(ptr, index, value) ptr[index] = value //@param ptr Pointer to add the value @param index Index of the value to add @param value Value to add
#define remove(ptr, index) ptr[index] = 0 //@param ptr Pointer to remove the value @param index Index of the value to remove #define removePTR(ptr, index) ptr[index] = 0 //@param ptr Pointer to remove the value @param index Index of the value to remove
#ifdef __INTELLISENSE__ #ifdef __INTELLISENSE__
#define create(type) ((type *)malloc(sizeof(type))) //@param type Type of the vector @example int *vector = create(int); #define create(type) ((type *)malloc(sizeof(type))) //@param type Type of the vector @example int *vector = create(int);

View File

@ -170,6 +170,28 @@ int main(void)
emcryptText(key2, req.key); emcryptText(key2, req.key);
writel(filepath, key2, 256); writel(filepath, key2, 256);
} }
else if (req.type == 2)
{
// debug
printf("Received request type 2\n");
char filepath[256];
printf("Received key: %s\n", req.key);
printf("Received level: %d\n", req.level);
sprintf(filepath, "%s%d.bin", PASSWORDS, req.level);
printf("Deleting key from file: %s\n", filepath);
if (remove(filepath) != 0)
{
fprintf(stderr, "Error deleting file\n");
}
}
else
{
fprintf(stderr, "Invalid request type\n");
}
} }
// Close the socket // Close the socket