An encoder is a device used to change a signal (such as a bitstream) or data into a code. The code may serve any of a number of purposes such as compressing information for transmission or storage, encrypting or adding redundancies to the input code, or translating from one code to another.
This is usually done by means of a programmed algorithm,especially if any part is digital, while most analog encoding is done with analog circuitry.