The practice of cryptography is as old as human civilization. As long as there have been people, there have been codes and ciphers.
Possibly the first known use of cryptography, dating back to ancient times, was by Julius Caesar in his private correspondence with his generals. Caesar used a simple substitution cipher in which letters were replaced by letters some fixed number of positions down the alphabet. He had a different code for each letter he used in his message. But this was not a system of encryption. It was just a series of symbols that were commonly-known at the time, which are used to represent letters in the Latin alphabet.
The Romans would use these symbols to represent letters in their messages, then an officer would use them in calculations (for example, figuring out how much food is needed for a certain number of troops). The calculation would produce nonsense symbols that were not decipherable by anyone else other than the person who knew how to do calculations in Roman numerals.