定制 tankfairies/enigma 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tankfairies/enigma

Composer 安装命令:

composer require tankfairies/enigma

包简介

Enigma Engine

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License Build Status

Enigma

Installation

Install with Composer:

composer require tankfairies/enigma

Details

This package provides the funtionality of 3 different Enigma models:

  • Wehrmacht / Luftwaffe 3 rotor model
  • Kriegsmarine 3 rotor model
  • Kriegsmarine 4 rotor model

Each model can be equipped with a different set of rotors and refelctors. All in all are 10 types of rotors and 4 types of refelctors available.

  • Wehrmacht / Luftwaffe 3 rotor model uses:
    • rotors: I, II, III, IV, V
    • reflectors: B, C
  • Kriegsmarine 3 rotor model uses:
    • rotors: I, II, III, IV, V, VI, VII, VIII
    • reflectors: B, C
  • Kriegsmarine 4 rotor model uses:
    • rotors: I, II, III, IV, V, VI, VII, VIII, Beta, Gamma
    • reflectors: B Thin, C Thin

Each rotor and reflector provides a unique wiring, which can not be changed. Settings are:

  • Contacts = ABCDEFGHIJKLMNOPQRSTUVWXYZ
  • I = EKMFLGDQVZNTOWYHXUSPAIBRCJ
  • II = AJDKSIRUXBLHWTMCQGZNPYFVOE
  • III = BDFHJLCPRTXVZNYEIWGAKMUSQO
  • IV = ESOVPZJAYQUIRHXLNFTGKDCMWB
  • V = VZBRGITYUPSDNHLXAWMJQOFECK
  • VI = JPGVOUMFYQBENHZRDKASXLICTW
  • VII = NZJHGRCXMYSWBOUFAIVLPEKQDT
  • VIII = FKQHTLXOCBJSPDZRAMEWNIUYGV
  • Beta = LEYJVCNIXWPBQMDRTAKZGFUHOS
  • Gamma = FSOKANUERHMBTIYCWLQPZXVGJD
  • B = YRUHQSLDPXNGOKMIEBFZCWVJAT
  • C = FVPJIAOYEDRZXWGCTKUQSBNMHL
  • B Thin = ENKQAUYWJICOPBLMDXZVFTHRGS
  • C Thin = RDOBJNTKVEHMLFCWZAXGYIPSUQ
  • Contacts = ABCDEFGHIJKLMNOPQRSTUVWXYZ

Rotors can have notches, which indicate the position where the next rotor is advanced. e.g.: Notch at position Q means, if rotor steps from Q to R, the next rotor is advanced. These positions are:

  • I = Q
  • II = E
  • III = V
  • IV = J
  • V = Z
  • VI, VII, VIII = Z + M

Each Rotor can be only used in one position at a time. Rotors I..VIII can be mounted at position 1, 2 or 3, wherelse rotors Beta and Gamma can only be used at position 4. Aditionally, Beta and Gamma can only be used in combination with reflector B Thin or C Thin, the others only with reflector B or C.

IMPORTANT

These conditions only apply if a proper emulation of the original Enigma is desired. This implementation allows to setup the rotors in any order, so its up to the user to take care of the order of rotors.

Usage

Instantiate a new instance of the library:

Reflectors

ReflectorInterface::REFLECTOR_B
ReflectorInterface::REFLECTOR_C
ReflectorInterface::REFLECTOR_BTHIN
ReflectorInterface::REFLECTOR_CTHIN

Rotors

RotorInterface::ROTOR_I
RotorInterface::ROTOR_II
RotorInterface::ROTOR_III
RotorInterface::ROTOR_IV
RotorInterface::ROTOR_V
RotorInterface::ROTOR_VI
RotorInterface::ROTOR_VII
RotorInterface::ROTOR_VIII
RotorInterface::ROTOR_BETA
RotorInterface::ROTOR_GAMMA

Code Example

use Tankfairies\Enigma\Enigma;

$enigma = new Enigma();
$enigma
    ->installRotors(new Rotor())
    ->installReflector(new Reflector())
    ->installWiring(new Wiring())
    ->installPlugboard(new Plugboard())
    ->installAplhabet(new Enigma\Alphabet());

$enigma
    ->setModel(EnigmaInterface::MODEL_KMM3)
    ->setRotors([
        RotorInterface::ROTOR_I,
        RotorInterface::ROTOR_II,
        RotorInterface::ROTOR_III
    ])
    ->setReflector(ReflectorInterface::REFLECTOR_B)
    ->initialise();

$this->enigma->setPosition(RotorInterface::ROTOR_I, "Q");
$this->enigma->setPosition(RotorInterface::ROTOR_II, "E");
$this->enigma->setPosition(RotorInterface::ROTOR_III, "V");

$this->enigma->setRingstellung(RotorInterface::ROTOR_I, "A");
$this->enigma->setRingstellung(RotorInterface::ROTOR_II, "A");
$this->enigma->setRingstellung(RotorInterface::ROTOR_III, "A");

$this->enigma->plugLetters("B", "Q");
$this->enigma->plugLetters("C", "R");
$this->enigma->plugLetters("D", "I");
$this->enigma->plugLetters("E", "J");
$this->enigma->plugLetters("K", "W");
$this->enigma->plugLetters("M", "T");
$this->enigma->plugLetters("O", "S");
$this->enigma->plugLetters("P", "X");
$this->enigma->plugLetters("U", "Z");
$this->enigma->plugLetters("G", "H");

$message = str_split("HELLOXWORLD");

$encoded = '';
foreach ($message as $character) {
    $encoded .= $this->enigma->encodeLetter($character);
}

Further Reading

http://en.wikipedia.org/wiki/Enigma_machine

http://users.telenet.be/d.rijmenants/

Credit

Thanks to Rafal Masiarek from Mustache Lab, as this was the inspiriation for this project. https://github.com/MustacheLab/PHP-Enigma

Copyright and license

The tankfairies/rulesengine library is Copyright (c) 2021 Tankfairies (https://tankfairies.com) and licensed for use under the MIT License (MIT).

tankfairies/enigma 适用场景与选型建议

tankfairies/enigma 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 08 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「encryption」 「enigma」 「code breaking」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tankfairies/enigma 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tankfairies/enigma 我们能提供哪些服务?
定制开发 / 二次开发

基于 tankfairies/enigma 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-03