# Escaping Printable Encoded Streams to Embed Out-of-Band Data
## 4 Printable Encodings and Case Studies of Payload Data Embedding  
Consider the set \(\mathcal{B}\) of all binary strings of length \(n\) bits; thus, \(\mathbf{card}(\mathcal{B})=2^{n}\). Furthermore, having an alphabet \(\boldsymbol{A}\) of \(t\) printable symbols compute the value \(v\) such that:  
\[v=\min\Bigl{\{}k\,|\,2^{n}\leq t^{k}\Bigr{\}} \tag{1}\]  
and define the set \(\mathcal{S}\) of all sequences of \(v\) symbols from the alphabet \(\boldsymbol{A}\): obviously, \(\mathbf{card}(\mathcal{S})=t^{v}\).  
Using \(2^{n}\) different sequences from \(\mathcal{S}\), it is possible to encode all the bit strings in \(\mathcal{B}\) using only symbols from \(\boldsymbol{A}\). It follows that there will be a subset \(\mathcal{E}\) of \(\mathcal{S}\) (\(\mathcal{E}\subseteq\mathcal{S}\)), whose elements are in one-to-one correspondence with the binary strings of \(\mathcal{B}\), that is, there is a bijection between \(\mathcal{E}\) and \(\mathcal{B}\), \(\mathcal{E}\Leftrightarrow\mathcal{B}\).  
Table 1 reports the characterizing values for some printable encodings.  
The set \(\mathcal{U}=\mathcal{S}-\mathcal{E}\), which contains the unused sequences of \(\mathcal{S}\), will have \(\mathbf{card}(\mathcal{U})=t^{v}-2^{n}\). From Table 1, it may be observed that this set \(\mathcal{U}\) is non-empty for Base41 [1], Base45 [5], Base85 [9], and Base91 [11].  
As previously said, in [6], the sequences in \(\mathcal{U}\) are employed for reversibly embedding data into a Base45 or Base85 encoded stream.  
Here, we propose a general framework for exploiting the unused sequences in several contexts, allowing applications to choose the most appropriate setting for their own purposes. Therefore, every application must define the meaning assigned to every unused sequence and how to process it. Suppose to encode binary sequences of \(n\) bits with \(v\) symbols belonging to an alphabet \(A\) (\(v\) is determined as in Equation (1)). If \(\mathcal{U}\
eq\varnothing\) (see, for example, the encodings with a non-zero value in the last column of Table 1), an application selects a set of sequences \(\mathcal{Z}\subseteq\mathcal{U}\) and assigns a meaning to every sequence \(\mathsf{S}\in\mathcal{Z}\). The semantics of each sequence must be known to both the encoder and decoder and agreed upon to have a correct transmission and extraction of the encoded data.  
As will be shown later on, a sequence \(\mathsf{S}\in\mathcal{Z}\) may represent:  
1. A string of bits encoding the whole or part of a Cyclic Redundancy Check (CRC) code;
2. A prefix indicating that a fixed number of following sequences encode a CRC, a Message Authentication Code, or a digital signature;
3. One or more bits to be transmitted separately from the data encoded by the sequences belonging to \(\mathcal{E}\);
4. A separator to split portions of the data stream encoded by the sequences in \(\mathcal{E}\);
5. An identifier specifying the characteristics of a portion of following sequences;
6. A context defining the meaning of the following sequences \(\mathsf{S}\in\mathcal{Z}\).  
For instance, an application that uses Base41 printable encodings can decide that the sequence \"zxx\" is a prefix indicating that the next two sequences represent a 32 bit CRC. Note that different applications can assign different meanings to the same sequence from \(\mathcal{Z}\).  
The next subsections will present some possible embodiments using the previously introduced representations.