Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to reproduce the German enigma password machine in World War II

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Take the four contacts as an example, in the forward propagation, we take the left contact as the benchmark, read the serial number of the right contact as 3412, in the back propagation, we take the right contact as the benchmark, and read the left contact serial number as 2413. How to build 2413 based on 3412 is a key. A friend of the author provides a good idea. Suppose 3412 is stored in list A, sorted from small to large, and stored in list B. Record the subscript of each element in list B in list An into list C, and list C is what we want.

After that, we can imitate the forward propagation and carry on the reverse propagation.

To talk about the use of the code, set up a file called enigma_code_book.txt in the same directory of the source code, which is used to roughly store the wiring of the Enigma machine model, three runners and a reflector.

Click on the run code, casually enter the enigma batch number composed of three groups of Arabic numerals, such as 123-456-789, click enter. At this time, the program will automatically generate the wiring method of the batch number enigma machine. If you have ever used this batch of Enigma machines, you will automatically find the desired wiring method in enigma_code_book.

Then enter the initial runner position, which is required to be three lowercase letters separated by commas, such as: a <... Enter, and then enter the encrypted plaintext content, enter, you can generate ciphertext.

If you want to decrypt, you are required to enter the same batch of secondary number, the same initial rotor position, enter ciphertext, you can decrypt the plaintext.

It should be noted that here, modelled on the enigma machine in history, only 26 lowercase letters are encrypted, but no numbers, capital letters and punctuation marks are encrypted. Because these are just some building blocks done on its basis according to different application needs. At the same time, the author also considered that if you want to encrypt Chinese, you can first expand the Enigma machine into uppercase letters and Arabic numerals, and then combine the value of base64.

At this point, the study on "how to use Python to reproduce the German enigma password machine in World War II" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report