---
name: "Eet_Data_Cipher_Group"
section: "3"
platform: "linux"
package: "libeet-doc"
version: "1.3.2-1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/Eet_Data_Cipher_Group"
---

# Eet\_Data\_Cipher\_Group(3)

Most of the Eet Data Serialization have alternative versions that accounts for ciphers to protect their content.

## NAME

Eet Data Serialization using A Ciphers -

Most of the **Eet Data Serialization** have alternative versions that accounts for ciphers to protect their content.

### Functions

EAPI void \* **eet\_data\_read\_cipher** (**Eet\_File** \*ef, **Eet\_Data\_Descriptor** \*edd, const char \*name, const char \*cipher\_key)\
 *Read a data structure from an eet file and decodes it using a cipher.*  EAPI int **eet\_data\_write\_cipher** (**Eet\_File** \*ef, **Eet\_Data\_Descriptor** \*edd, const char \*name, const char \*cipher\_key, const void \*data, int compress)\
 *Write a data structure from memory and store in an eet file using a cipher.*  EAPI int **eet\_data\_text\_dump\_cipher** (const void \*data\_in, const char \*cipher\_key, int size\_in, void(\*dumpfunc)(void \*data, const char \*str), void \*dumpdata)\
 *Dump an eet encoded data structure into ascii text using a cipher.*  EAPI void \* **eet\_data\_text\_undump\_cipher** (const char \*text, const char \*cipher\_key, int textlen, int \*size\_ret)\
 *Take an ascii encoding from* **eet\_data\_text\_dump()** *and re-encode in binary using a cipher.*  EAPI int **eet\_data\_dump\_cipher** (**Eet\_File** \*ef, const char \*name, const char \*cipher\_key, void(\*dumpfunc)(void \*data, const char \*str), void \*dumpdata)\
 *Dump an eet encoded data structure from an eet file into ascii text using a cipher.*  EAPI int **eet\_data\_undump\_cipher** (**Eet\_File** \*ef, const char \*name, const char \*cipher\_key, const char \*text, int textlen, int compress)\
 *Take an ascii encoding from* **eet\_data\_dump()** *and re-encode in binary using a cipher.*  EAPI void \* **eet\_data\_descriptor\_decode\_cipher** (**Eet\_Data\_Descriptor** \*edd, const void \*data\_in, const char \*cipher\_key, int size\_in)\
 *Decode a data structure from an arbitary location in memory using a cipher.*  EAPI void \* **eet\_data\_descriptor\_encode\_cipher** (**Eet\_Data\_Descriptor** \*edd, const void \*data\_in, const char \*cipher\_key, int \*size\_ret)\
 *Encode a data struct to memory and return that encoded data using a cipher.*

## Detailed Description

Most of the **Eet Data Serialization** have alternative versions that accounts for ciphers to protect their content.

**See also:**

**Cipher, Identity and Protection Mechanisms**

## Function Documentation

### EAPI void\* eet\_data\_descriptor\_decode\_cipher (Eet\_Data\_Descriptor \* edd, const void \* data\_in, const char \* cipher\_key, int size\_in)

Decode a data structure from an arbitary location in memory using a cipher. **Parameters:**

*edd* The data descriptor to use when decoding. \
 *data\_in* The pointer to the data to decode into a struct. \
 *cipher\_key* The key to use as cipher. \
 *size\_in* The size of the data pointed to in bytes.

**Returns:**

NULL on failure, or a valid decoded struct pointer on success.

This function will decode a data structure that has been encoded using **eet\_data\_descriptor\_encode()**, and return a data structure with all its elements filled out, if successful, or NULL on failure.

The data to be decoded is stored at the memory pointed to by `data_in`, and is described by the descriptor pointed to by `edd`. The data size is passed in as the value to `size_in`, ande must be greater than 0 to succeed.

This function is useful for decoding data structures delivered to the application by means other than an eet file, such as an IPC or socket connection, raw files, shared memory etc.

Please see **eet\_data\_read()** for more information.

**See also:**

**eet\_data\_descriptor\_decode()**

**Since:**

1\.0.0

Referenced by eet\_data\_descriptor\_decode().

### EAPI void\* eet\_data\_descriptor\_encode\_cipher (Eet\_Data\_Descriptor \* edd, const void \* data\_in, const char \* cipher\_key, int \* size\_ret)

Encode a data struct to memory and return that encoded data using a cipher. **Parameters:**

*edd* The data descriptor to use when encoding. \
 *data\_in* The pointer to the struct to encode into data. \
 *cipher\_key* The key to use as cipher. \
 *size\_ret* pointer to the an int to be filled with the decoded size.

**Returns:**

NULL on failure, or a valid encoded data chunk on success.

This function takes a data structutre in memory and encodes it into a serialised chunk of data that can be decoded again by **eet\_data\_descriptor\_decode()**. This is useful for being able to transmit data structures across sockets, pipes, IPC or shared file mechanisms, without having to worry about memory space, machine type, endianess etc.

The parameter `edd` must point to a valid data descriptor, and `data_in` must point to the right data structure to encode. If not, the encoding may fail.

On success a non NULL valid pointer is returned and what `size_ret` points to is set to the size of this decoded data, in bytes. When the encoded data is no longer needed, call free() on it. On failure NULL is returned and what `size_ret` points to is set to 0.

Please see **eet\_data\_write()** for more information.

**See also:**

**eet\_data\_descriptor\_encode()**

**Since:**

1\.0.0

Referenced by eet\_connection\_send(), and eet\_data\_descriptor\_encode().

### EAPI int eet\_data\_dump\_cipher (Eet\_File \* ef, const char \* name, const char \* cipher\_key, void(\*)(void \*data, const char \*str) dumpfunc, void \* dumpdata)

Dump an eet encoded data structure from an eet file into ascii text using a cipher. **Parameters:**

*ef* A valid eet file handle. \
 *name* Name of the entry. eg: '/base/file\_i\_want'. \
 *cipher\_key* The key to use as cipher. \
 *dumpfunc* The function to call passed a string when new data is converted to text \
 *dumpdata* The data to pass to the `dumpfunc` callback.

**Returns:**

1 on success, 0 on failure

This function will take an open and valid eet file from **eet\_open()** request the data encoded by **eet\_data\_descriptor\_encode()** corresponding to the key `name` and convert it into human readable ascii text. It does this by calling the `dumpfunc` callback for all new text that is generated. This callback should append to any existing text buffer and will be passed the pointer `dumpdata` as a parameter as well as a string with new text to be appended.

**See also:**

**eet\_data\_dump()**

**Since:**

1\.0.0

References eet\_dictionary\_get(), eet\_node\_del(), eet\_node\_dump(), eet\_read\_cipher(), and eet\_read\_direct().

Referenced by eet\_data\_dump().

### EAPI void\* eet\_data\_read\_cipher (Eet\_File \* ef, Eet\_Data\_Descriptor \* edd, const char \* name, const char \* cipher\_key)

Read a data structure from an eet file and decodes it using a cipher. **Parameters:**

*ef* The eet file handle to read from. \
 *edd* The data descriptor handle to use when decoding. \
 *name* The key the data is stored under in the eet file. \
 *cipher\_key* The key to use as cipher.

**Returns:**

A pointer to the decoded data structure.

This function decodes a data structure stored in an eet file, returning a pointer to it if it decoded successfully, or NULL on failure. This can save a programmer dozens of hours of work in writing configuration file parsing and writing code, as eet does all that work for the program and presents a program-friendly data structure, just as the programmer likes. Eet can handle members being added or deleted from the data in storage and safely zero-fills unfilled members if they were not found in the data. It checks sizes and headers whenever it reads data, allowing the programmer to not worry about corrupt data.

Once a data structure has been described by the programmer with the fields they wish to save or load, storing or retrieving a data structure from an eet file, or from a chunk of memory is as simple as a single function call.

**See also:**

**eet\_data\_read()**

**Since:**

1\.0.0

References eet\_dictionary\_get(), eet\_read\_cipher(), and eet\_read\_direct().

Referenced by eet\_data\_read().

### EAPI int eet\_data\_text\_dump\_cipher (const void \* data\_in, const char \* cipher\_key, int size\_in, void(\*)(void \*data, const char \*str) dumpfunc, void \* dumpdata)

Dump an eet encoded data structure into ascii text using a cipher. **Parameters:**

*data\_in* The pointer to the data to decode into a struct. \
 *cipher\_key* The key to use as cipher. \
 *size\_in* The size of the data pointed to in bytes. \
 *dumpfunc* The function to call passed a string when new data is converted to text \
 *dumpdata* The data to pass to the `dumpfunc` callback.

**Returns:**

1 on success, 0 on failure

This function will take a chunk of data encoded by **eet\_data\_descriptor\_encode()** and convert it into human readable ascii text. It does this by calling the `dumpfunc` callback for all new text that is generated. This callback should append to any existing text buffer and will be passed the pointer `dumpdata` as a parameter as well as a string with new text to be appended.

Example:

```
 void output(void *data, const char *string)
 {
   printf('%s', string);
 }
 void dump(const char *file)
 {
   FILE *f;
   int len;
   void *data;
   f = fopen(file, 'r');
   fseek(f, 0, SEEK_END);
   len = ftell(f);
   rewind(f);
   data = malloc(len);
   fread(data, len, 1, f);
   fclose(f);
   eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
 }
```

**See also:**

**eet\_data\_text\_dump()**

**Since:**

1\.0.0

References eet\_node\_del(), and eet\_node\_dump().

Referenced by eet\_data\_text\_dump().

### EAPI void\* eet\_data\_text\_undump\_cipher (const char \* text, const char \* cipher\_key, int textlen, int \* size\_ret)

Take an ascii encoding from **eet\_data\_text\_dump()** and re-encode in binary using a cipher. **Parameters:**

*text* The pointer to the string data to parse and encode. \
 *cipher\_key* The key to use as cipher. \
 *textlen* The size of the string in bytes (not including 0 byte terminator). \
 *size\_ret* This gets filled in with the encoded data blob size in bytes.

**Returns:**

The encoded data on success, NULL on failure.

This function will parse the string pointed to by `text` and return an encoded data lump the same way **eet\_data\_descriptor\_encode()** takes an in-memory data struct and encodes into a binary blob. `text` is a normal C string.

**See also:**

**eet\_data\_text\_undump()**

**Since:**

1\.0.0

Referenced by eet\_data\_text\_undump().

### EAPI int eet\_data\_undump\_cipher (Eet\_File \* ef, const char \* name, const char \* cipher\_key, const char \* text, int textlen, int compress)

Take an ascii encoding from **eet\_data\_dump()** and re-encode in binary using a cipher. **Parameters:**

*ef* A valid eet file handle. \
 *name* Name of the entry. eg: '/base/file\_i\_want'. \
 *cipher\_key* The key to use as cipher. \
 *text* The pointer to the string data to parse and encode. \
 *textlen* The size of the string in bytes (not including 0 byte terminator). \
 *compress* Compression flags (1 == compress, 0 = don't compress).

**Returns:**

1 on success, 0 on failure

This function will parse the string pointed to by `text`, encode it the same way **eet\_data\_descriptor\_encode()** takes an in-memory data struct and encodes into a binary blob.

The data (optionally compressed) will be in ram, pending a flush to disk (it will stay in ram till the eet file handle is closed though).

**See also:**

**eet\_data\_undump()**

**Since:**

1\.0.0

References eet\_dictionary\_get(), and eet\_write\_cipher().

Referenced by eet\_data\_undump().

### EAPI int eet\_data\_write\_cipher (Eet\_File \* ef, Eet\_Data\_Descriptor \* edd, const char \* name, const char \* cipher\_key, const void \* data, int compress)

Write a data structure from memory and store in an eet file using a cipher. **Parameters:**

*ef* The eet file handle to write to. \
 *edd* The data descriptor to use when encoding. \
 *name* The key to store the data under in the eet file. \
 *cipher\_key* The key to use as cipher. \
 *data* A pointer to the data structure to ssave and encode. \
 *compress* Compression flags for storage.

**Returns:**

bytes written on successful write, 0 on failure.

This function is the reverse of **eet\_data\_read()**, saving a data structure to an eet file.

**See also:**

**eet\_data\_write\_cipher()**

**Since:**

1\.0.0

References eet\_dictionary\_get(), and eet\_write\_cipher().

Referenced by eet\_data\_write().

## Author

Generated automatically by Doxygen for Eet from the source code.
