A new method for error-correcting coding is proposed. It is based on processing information messages by finite automata and using a two-base numeral system. The two-level structure of an encoder provides powerful error-correcting capabilities. On the first (internal) level, an input message is considered as a binary number represented as a lower (2,3) code that has some redundancy and error-correcting properties. The noise-resistant properties are strengthened on the external level where the code is processed by a special finite automaton. It is a variable-length code, i.e., the codeword length depends not only on the length of an input message but also on the message content. However, the average code rate equals 1/2.