When Thomas Jefferson was president of the United States, he invented a mechanism for generating secret codes that was so effective it was used for the next one hundred years.