cancel
Showing results for 
Search instead for 
Did you mean: 

Encryption csv file

Nico3
Senior

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 ?

 

5 REPLIES 5

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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. 

 

 

 

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 ?  

 

 

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..