word-forming element meaning "in; into," from French and Old French en-, from Latin in- "in, into" (from PIE root *en "in"). Typically assimilated before -p-, -b-, -m-, -l-, and -r-. Latin in- became en- in French, Spanish, Portuguese, but remained in- in Italian.
Also used with native and imported elements to form verbs from nouns and adjectives, with a sense "put in or on" (encircle), also "cause to be, make into" (endear), and used as an intensive (enclose). Spelling variants in French that were brought over into Middle English account for parallels such as ensure/insure, and most en- words in English had at one time or another a variant in in-, and vice versa.
c. 1300, "systematic compilation of laws," from Old French code "system of laws, law-book" (13c.), from Latin codex"systematic classification of statutory law," earlier caudex "book," literally "tree trunk," hence, book made up of wooden tablets covered with wax for writing. De Vaan traces this through Proto-Italic *kaud-ek- to PIE *kehu-d- "cleaved, separate," which he also sees as the root of cauda "tail" (see coda).
Meaning "cipher, system of signals and the rules which govern their use" (the sense in secret code) is from 1808. Code-name is from 1879 (in telegraphy). Meaning "system of expressing information and instructions in a form usable by a computer" is from 1946.