PHP Classes

Simple PHP Enigma Machine: Encrypt and decrypt data like the Enigma machine

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 161 All time: 8,946 This week: 571Up
Version License PHP version Categories
simple 1.0.0The PHP License7.3PHP 5, Cryptography
Description 

Author

This package can encrypt and decrypt data like the Enigma machine.

It can take a list of rotator characters that act as key and encrypts a given text string.

The package can also do the opposite, i.e. it takes a given encrypted message and decrypts it using the reverse process.

Innovation Award
PHP Programming Innovation award winner
December 2019
Winner
The Enigma machine was a well-known electro-mechanical computer that was used during World War II to help allies win the war.

This package implements the encryption algorithms in PHP that are similar to used implemented by the Enigma machine.

Manuel Lemos
Picture of adam berger
  Performance   Level  
Name: adam berger <contact>
Classes: 23 packages by
Country: Poland Poland
Age: ???
All time rank: 74621 in Poland Poland
Week rank: 51 Up3 in Poland Poland Up
Innovation award
Innovation award
Nominee: 8x

Winner: 2x

Example

<?php
namespace EnigmaKriegsmarine
{
require_once(
"EnigmaKriegsmarine/ClassEnigma.php");

            
// Przestrzen nazw
         // Namespace
             
use EnigmaKriegsmarine;
        
// Wywolanie klasy
   
$enigma = new EnigmaKriegsmarine\ClassEnigma();

 
// Ustawiamy kod dla rotatorów (Ksiazka kodów szyfrujacych)
  // Set the code for rotators (Encryption Code Book)
   
$textBoxBeben1="B";
   
$textBoxBeben2="E";
   
$textBoxBeben3="R";
   
$textBoxBeben4="N";
   
$textBoxBeben5="I";
   
$textBoxBeben6="K";
   
$textBoxBeben7="O";
   
$textBoxBeben8="L";
   
$textBoxBeben9="1";
   
$textBoxBeben10="8";
   
    
// Przypisujemy wybrany kod do rotatorów
     // We assign the selected code to rotators
   
$enigma->WybraneBebnySzyfrujace( $textBoxBeben1, $textBoxBeben2,
                                    
$textBoxBeben3, $textBoxBeben4,
                                    
$textBoxBeben5, $textBoxBeben6,
                                    
$textBoxBeben7, $textBoxBeben8,
                                    
$textBoxBeben9, $textBoxBeben10 );

    
$string = "ENIGMAKREGSMARINE";
     for(
$i=0; $i<strlen($string);$i++)
     {
   
$enigma->SzyfrowanieInput($string[$i]);
     }
   
// Podajemy teks do zaszyfrowania
    // Enter the text to be encrypted
    //$enigma->SzyfrowanieInput("E");
    //$enigma->SzyfrowanieInput("N");
    //$enigma->SzyfrowanieInput("I");
    //$enigma->SzyfrowanieInput("G");
    //$enigma->SzyfrowanieInput("M");
    //$enigma->SzyfrowanieInput("A");
    //$enigma->SzyfrowanieInput("K");
    //$enigma->SzyfrowanieInput("R");
    //$enigma->SzyfrowanieInput("I");
    //$enigma->SzyfrowanieInput("E");
    //$enigma->SzyfrowanieInput("G");
    //$enigma->SzyfrowanieInput("S");
    //$enigma->SzyfrowanieInput("M");
    //$enigma->SzyfrowanieInput("A");
    //$enigma->SzyfrowanieInput("R");
    //$enigma->SzyfrowanieInput("I");
    //$enigma->SzyfrowanieInput("N");
    //$enigma->SzyfrowanieInput("E");

    // Wypisujemy na ekranie tekst do zaszyfrowania
    // Enter the text to be encrypted on the screen
       
$tab2 = $enigma->TextSzyfrowanieTab();
       
$text = "<br>Tekst do zaszyfrowania-> ";
    for(
$i=0; $i<Count($tab2); $i++)
    {
       
$text .= $tab2[$i];
    }
      echo
$text .= "<br>";
   
// Tablica tekstu zaszyfrowanego, Wypisujemy na ekranie
    // Table of encrypted text, We type on the screen
                  
$tab = $enigma->SzyfrowanieOutputTab();
       
$text = "<br>Tekst zaszyfrowany -> ";
    for(
$i=0; $i<Count($tab); $i++)
    {
       
$text .= $tab[$i];
    }
      echo
$text .= "<br>";

  
// Podajemy teks do odszyfrowania
   // We give the text to decrypt
    
$string = "9IEDK0KSKHKXSHZRXP";
     for(
$i=0; $i<strlen($string);$i++)
     {
   
$enigma->DeszyfrowanieInput($string[$i]);
     }
   
//$enigma->DeszyfrowanieInput("9");
    //$enigma->DeszyfrowanieInput("I");
    //$enigma->DeszyfrowanieInput("E");
    //$enigma->DeszyfrowanieInput("D");
    //$enigma->DeszyfrowanieInput("K");
    //$enigma->DeszyfrowanieInput("0");
    //$enigma->DeszyfrowanieInput("K");
    //$enigma->DeszyfrowanieInput("S");
    //$enigma->DeszyfrowanieInput("K");
    //$enigma->DeszyfrowanieInput("H");
    //$enigma->DeszyfrowanieInput("K");
    //$enigma->DeszyfrowanieInput("X");
    //$enigma->DeszyfrowanieInput("S");
    //$enigma->DeszyfrowanieInput("H");
    //$enigma->DeszyfrowanieInput("Z");
    //$enigma->DeszyfrowanieInput("R");
    //$enigma->DeszyfrowanieInput("X");
    //$enigma->DeszyfrowanieInput("P");
 
  // tablica z calym tekstem Wypisujemy na ekranie
  // table with all text Enter on the screen
  
$tab3 = $enigma->TextDeszyfrowanieTab();
 
 
$text = "<br>Tekst do rozszyfrowania -> ";
    for(
$i=0; $i<Count($tab3); $i++)
    {
       
$text .= $tab3[$i];
    }
      echo
$text .= "<br>";
 
   
// Tablica tekstu zdeszyfrowanego, Wypisujemy na ekranie
    // Table of encrypted text, Type on the screen
      
$tab1 = $enigma->DeszyfrowanieOutput();
      
$text = "<br>Tekst zdeszyfrowany -> ";
    for(
$i=0; $i<Count($tab1); $i++)
    {
       
$text .= $tab1[$i];
    }
       echo
$text .= "<br>";
}
?>


Details

Simple Enigma Kriegsmarine

Enigma for 10 Encryption Drums. For 10 rotator 36x36x36x36x36x36x36x36x36x36 = 3 656 158 440 062 976 brutal force. PHP 7.3 more information here http://www.joomla-cms.com.pl/pl/ciekawostki/?atwa-enigma-kriegsmarine-w-php-7-3.html


Screenshots  
  • Enigma-Kregsmarine
  Files folder image Files  
File Role Description
Files folder imageEnigmaKriegsmarine (3 files)
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  EnigmaKriegsmarine  
File Role Description
  Plain text file ClassEnigma.php Class Class source
  Plain text file EncryptionAndDecryption.php Class Class source
  Plain text file ValidateTrait.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 83%
Total:161
This week:0
All time:8,946
This week:571Up