2024-05-04 01:36 AM - edited 2024-05-04 05:03 AM
Hello
MCU has SD card & USB in MSC Device mode. I am storing data on SD card in csv fatfs format. The data from SD card can be read on computer by making connecting with USB.
Now I want to encrypt the data so only my GUI application software on computer can read the csv files, otherwise anyone can open the stored csv file.
I have no experience with encyption and have tried to search forums and see link to playlist on STM cryptography. Should i watch that ?
2024-05-04 05:05 AM
fopen, fread, fwrite, etc operate in similar ways for text and binary, it's all just "data" in 8-bit from the computer's perspective. Perhaps start with numeric representation within computers, and representation of data in memory and files?
Perhaps you can do some sort rotating Vigenere Cipher on the output of numeric values? Basically in the output routines to obfuscate the values you want to protect? A predictable pseudo-range sequence,
ie
digit = (digit + sequence(i++)) %10; // encipher
then
digit = (digit + 10 - sequence(i++)) %10; // decipher
https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
2024-05-04 05:33 AM
ok,,
I went through rotating Vigenere Cipher and understood , so only user with known key will be able to decipher the text.
Is there any other better way ? I see some devices have encrypted .bin file. Is there any library for this ? I prefer this method if possible.
2024-05-04 06:27 AM
I found sample code to convert txt to Binary then back to txt.
First I should encrypt the txt file
after that convert to Binary .. correct ?
2024-05-04 11:07 AM
You need something that works at both ends. ie STM32 and PC side
There's AES in various forms. Plenty of examples on the web.
All files are "binary", something with ASCII data will be easier for a beginner to work with.
2024-05-04 11:10 AM
All the data in memory is in an 8-bit binary form. You'd save to to a file via f_write() for FATFS, or fwrite() for STDIO.
Code an application on a PC first so you can understand / practice the encrypt / decrypt methods.