Skip to content

Simple implementation of Vigenere Cipher algorithm in PHP, also implement modification to support alpha-numeric characters

Notifications You must be signed in to change notification settings

amculin/php-vigenere-cipher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implementation of Vigenere Cipher in PHP

Packagist Download GitHub Repo stars Packagist Version Passed Build Workflow Passed PHPStan Level 10

Encrypt/decrypt string using Vigenere Cipher algorithm

Instalation

composer require amculin/vigenere-cipher

How to use

Encryption

use amculin\cryptography\classic\VigenereCipher;

$data = 'testtheencryptionprocess';
$key = 'thisisthekey';

//Basic mode only support lowercase alphabet
//You can use alpha_numeric mode for wider supported characters (a-z, A-Z, 0-9)
$encrypted = VigenereCipher::encrypt($data, $key, 'basic');

echo "Plain text: {$data}\n";
echo "Key: {$key}\n";
echo "Cipher Text: {$encrypted}\n";

Output:

Plain text: testtheencryptionprocess
Key: thisisthekey
Cipher Text: mlalbzxlrmvwiaqgvhkvgowq

Decryption

use amculin\cryptography\classic\VigenereCipher;

$data = 'mlalbzxlrmvwiaqgvhkvgowq';
$key = 'thisisthekey';
$decrypted = VigenereCipher::decrypt($data, $key, 'basic');

echo "Cipher text: {$data}\n";
echo "Key: {$key}\n";
echo "Plain Text: {$decrypted}\n";

Output:

Cipher Text: mlalbzxlrmvwiaqgvhkvgowq
Key: thisisthekey
Plain text: testtheencryptionprocess

Features

  • Support basic mode/lowercase alphabet only
  • Support alpha-numeric mode (a-z, A-Z, 0-9)
  • Unit test
  • Comply PHPStan Level 10

Todos

  • Add ASCII mode to support file encryption/decryption
  • Add Base64 mode to support Base64 string

About

Simple implementation of Vigenere Cipher algorithm in PHP, also implement modification to support alpha-numeric characters

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages