增加文件解密代码
This commit is contained in:
parent
bc481bd691
commit
72b3084f70
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
file(GLOB PORT_SRCS "wifi/*.c" )
|
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"
|
idf_component_register(SRCS "main.c" "usb_serial_task" "Receiver.c"
|
||||||
${PORT_SRCS}
|
${PORT_SRCS}
|
||||||
|
|||||||
8
main/file_system/file_encryptor.c
Normal file
8
main/file_system/file_encryptor.c
Normal 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 加密/解密
|
||||||
|
}
|
||||||
|
}
|
||||||
11
main/file_system/file_encryptor.h
Normal file
11
main/file_system/file_encryptor.h
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user