Python code of Enigma with one works similar of real model Enigma with was used due WW2 This code specialized specifically for the Russian language, but you can change the language yourself by analyzing the code.
I also posted a crypto-analytical algorithm for frequency analysis wich one saves in file "proc_of_letters.txt" result of analis and i posted clear substitution cipher