德国密码机命令行工具
enigma-cli的Python项目详细描述
Author: | Cory J. Engdahl |
---|---|
Email: | cjengdahl@gmail.com |
Webpage: | http://www.cjengdahl.com |
License: | MIT |
说明
德国谜机命令行工具(谜,M1,M2,M3,M4型号)。 复制二战中使用的物理机器的确切功能 具有易于使用的命令行界面。
配置
就像一个真正的谜机,模拟机必须在使用前配置。配置 充当“钥匙”。相同的密钥用于加密和解密文本。安装配置存储在一个配置文件中,可以通过命令行界面对其进行修改。默认配置与名为“user”的单个可修改用户配置一起始终可用。它是必需的 在使用前指定以下项目:
- 谜模型
- 使用的转子(ID)
- 转子启动位置
- 转子环位置
- 反射镜
- 插入插板的插头
首选项
除了机器配置,还可以设置用户首选项。这些包括输出分组、换行删除、空间处理、空间检测、默认配置、状态记忆和progressbar包含。
详细的首选项说明:
- 输出分组将输出文本分组到指定的字符数。历史上,每五个字符用空格隔开的信息。如果空间处理首选项设置为“keep”或“x”,则忽略此首选项。
- newline删除用空格替换换行符。这只适用于文件输入,而不是直接从标准输入加密。
- space handling允许用户在加密前指定是否应在密码文本中保留空格、删除空格或用“x”替换空格。历史上,用“x”代替空格是很常见的,因为字符本身并不常用。
- space detection与space replacement密切相关。在解密过程中,如果找到一个“x”,它将被替换为一个空格。
- 默认配置是每次执行enigma命令时自动加载的配置。默认情况下,将加载“用户”配置;但是,可以指定添加配置。
- 谜团可以置于记忆状态。启用此选项后,对于每一个加密/解密的字符,将保存下一次使用的机器状态(即使用后保存转子位置)
- 最后,在加密或解密以显示经过的进度时,命令行可以包含progressbar。
用法
谜[选项]命令[参数]…
命令如下所示:
加密<;文本>;
使用Enigma机器加密文本输入。所有输入都转换为大写,并删除非字母字符(空格和换行符除外)。文本是可选的,优先于文件输入。
别名:解密
选项:
^{tt2}$ Set space handling preference ^{tt3}$ Include newline characters ^{tt4}$ Convert decrypted Xs to spaces ^{tt5}$ Set output letter grouping ^{tt6}$ Enigma machine model ^{tt7}$ Fast rotor config: id (1-8) , position (1-26), and ring setting (1-26) ^{tt8}$ Middle rotor config: id (1-8) , position (1-26), and ring setting (1-26) ^{tt9}$ Slow rotor config: id (1-8) , position (1-26), and ring setting (1-26) ^{tt10}$ Static rotor config: (9 for beta, 10 for gamma), position (1-26), and ring setting (1-26) ^{tt11}$ Enigma reflector ^{tt12}$ Plugs inserted in plugboard (e.g. “AB,XY”) ^{tt13}$ Select enigma machine configuration ^{tt14}$ Overwrite config file with invoked preferences, and options ^{tt15}$ Remember machine state after encryption ^{tt16}$ Path to input file ^{tt17}$ Path to output file
清除
清除除“默认”和“用户”之外的所有用户配置。
删除<;配置>;
删除指定的用户配置。无法删除默认和用户配置
列表<;配置>;
列出了现有的用户配置。如果将特定配置作为参数提供,则列出配置详细信息
新配置
选项:
^{tt18}$ Enigma machine model ^{tt7}$ Fast rotor config: id (1-8) , position (1-26), and ring setting (1-26) ^{tt8}$ Middle rotor config: id (1-8) , position (1-26), and ring setting (1-26) ^{tt9}$ Slow rotor config: id (1-8) , position (1-26), and ring setting (1-26) ^{tt10}$ Static rotor config: (9 for beta, 10 for gamma), position (1-26), and ring setting (1-26) ^{tt11}$ Enigma reflector ^{tt12}$ Plugs inserted in plugboard (e.g. “AB,XY”)
pref
管理默认首选项。调用的选项将更新首选项
选项:
^{tt2}$ Set space handling preference ^{tt3}$ Include newline characters ^{tt4}$ Convert decrypted Xs to spaces ^{tt5}$ Set output letter grouping ^{tt13}$ Select enigma machine configuration ^{tt15}$ Remember machine state after encryption ^{tt31}$ Show progressbar
重置<;配置>;
将指定的配置重置为“默认”设置。
基本示例
创建新配置:
$ enigma new config1 --model M3 --fast 1,2,3 --middle 5,12,23 --slow 2,17,9 --plugs AB,GD,KL,IU --reflect UKW-B
encrypt来自标准输入:
$ enigma pref --select config1 $ enigma encrypt "Hello World" Encrypting [####################################] 100% CMQYT PZVTS
encrypt来自文件输入,保留空格:
$ enigma encrypt -f /usr/share/dict/words -o ~/Desktop/demo.txt Encrypting [####################################] 100% $ less ~/Desktop/demo.txt Y B PV U BW LEK KW BBD LZSO V DPGRT PS PWZ SXDJL KFIRL RFMNA FT QGN KMNTC O BZDJ SQDT C VXCAP BTQ . . .