Eet data cipher/decipher example

In this example, we exemplify the usage of eet_write_cipher() and eet_read_cipher().

For it to work, make sure to have your Eet installation with a ciphering backend enabled.

We start by defining the information to record in an Eet file (buffer), the key to cipher that (key) and a dummy wrong key to try to access that information, later (key_bad).

After opening our file, we simply use the first cited function to write our string ciphered:

Then, after closing it on purpose, we open it again, to retrieve the encrypted information back, in a readable format:

Note that we do it twice, being the last time with the wrong key. In this last case, if the information is read back and matches the original buffer, something wrong is going on (we made it to fail on purpose). The former access is OK, and must work.

What we do in sequence is just to delete the file. The complete code of the example follows.