增加文件解密代码

This commit is contained in:
YuXifeng 2025-03-24 21:46:58 +08:00
parent bc481bd691
commit 72b3084f70
3 changed files with 20 additions and 1 deletions

View File

@ -1,7 +1,7 @@
file(GLOB PORT_SRCS "wifi/*.c" )
file(GLOB FILE_SYS_SRCS "file_system/spiffs.c" )
file(GLOB FILE_SYS_SRCS "file_system/spiffs.c" "file_system/file_encryptor.c" )
idf_component_register(SRCS "main.c" "usb_serial_task" "Receiver.c"
${PORT_SRCS}

View File

@ -0,0 +1,8 @@
#include "file_encryptor.h"
// XOR 加密/解密
void xor_encrypt_decrypt(uint8_t *data, size_t data_len, const uint8_t *key, size_t key_len) {
for (size_t i = 0; i < data_len; ++i) {
data[i] ^= key[i % key_len]; // 使用密钥进行 XOR 加密/解密
}
}

View File

@ -0,0 +1,11 @@
#ifndef FILE_ENCRYPTOR_H
#define FILE_ENCRYPTOR_H
#include "esp_log.h"
#include "esp_system.h"
// 加密/解密方法:这里我们将使用 XOR 加密
void xor_encrypt_decrypt(uint8_t *data, size_t data_len, const uint8_t *key, size_t key_len);
#endif // FILE_ENCRYPTOR_H