Skip to main content
Senior
May 4, 2024
Question

Encryption csv file

  • May 4, 2024
  • 1 reply
  • 1738 views

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 ?

 

1 reply

Tesla DeLorean
Guru
May 4, 2024

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 VenmoUp vote any posts that you find helpful, it shows what's working..
Nico3Author
Senior
May 4, 2024

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. 

 

 

 

Nico3Author
Senior
May 4, 2024

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 ?