Mealy machines to model ciphers
Consider the coding $a \to 0$, $b \to 1010$, $c \to 100$, $d \to 1011$, $r \to 11$.$\ \ $  I let you guess what represents $010101101000101101010110$ in this coding, but this can be easily computed by a sequential machine, as illustrated
here, slides 9-10.

What is the theory behind this? A subset $P$ of $A^+$ is a prefix code if no element of $P$ is a proper prefix of another element in $P$. For instance, the sets $\{0, 1010, 100, 1011, 11\}$, $0^*1$ and $\{0^n1^n \mid n &gt; 0\}$ are prefix codes, with $A = \{0, 1\}$. Prefix codes are conveniently represented by the leaves of a tree. In particular, variable-length Huffman codes, the UTF-8 code and the Morse code are of this type.

Now if $B$ is another alphabet and $f:B \to P$ is an injective function, then $f$ extends uniquely to an injective monod morphism (coding) from $B^*$ to $A^*$. Further, if $P$ is a finite subset of $A^+$, the decoding function $f^{-1}$ can be computed by a sequential machine. This machine is essentially the minimal automaton of $P^*$, equipped with appropriate outputs (see the example).

Variable-length codes (whose prefix codes are a special case of) form the topic a rather advanced theory. The main reference is:
J. Berstel, D. Perrin, C. Reutenauer, Codes and automata. Encyclopedia of Mathematics and its Applications 129. Cambridge: Cambridge University Press (2010). ISBN 978-0-521-88831-8.