-
-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix cs errors to follow the psr12 standard and also some minor fixes
- Loading branch information
1 parent
d7d34e3
commit ebd1fa8
Showing
71 changed files
with
571 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
<?php | ||
// A mono-alphabetic cipher is a simple substitution cipher | ||
// https://www.101computing.net/mono-alphabetic-substitution-cipher/ | ||
|
||
function monoAlphabeticCipher($key, $alphabet, $text){ | ||
|
||
$cipherText = ''; // the cipher text (can be decrypted and encrypted) | ||
|
||
if ( strlen($key) != strlen($alphabet) ) { return false; } // check if the text length matches | ||
$text = preg_replace('/[0-9]+/', '', $text); // remove all the numbers | ||
|
||
for( $i = 0; $i < strlen($text); $i++ ){ | ||
$index = strripos( $alphabet, $text[$i] ); | ||
if( $text[$i] == " " ){ $cipherText .= " "; } | ||
else{ $cipherText .= ( ctype_upper($text[$i]) ? strtoupper($key[$index]) : $key[$index] ); } | ||
} | ||
return $cipherText; | ||
} | ||
|
||
function maEncrypt($key, $alphabet, $text){ | ||
|
||
return monoAlphabeticCipher($key, $alphabet, $text); | ||
|
||
} | ||
|
||
function maDecrypt($key, $alphabet, $text){ | ||
|
||
return monoAlphabeticCipher($alphabet, $key, $text); | ||
|
||
} | ||
|
||
?> | ||
<?php | ||
|
||
// A mono-alphabetic cipher is a simple substitution cipher | ||
// https://www.101computing.net/mono-alphabetic-substitution-cipher/ | ||
|
||
function monoAlphabeticCipher($key, $alphabet, $text) | ||
{ | ||
$cipherText = ''; // the cipher text (can be decrypted and encrypted) | ||
|
||
if (strlen($key) != strlen($alphabet)) { | ||
return false; | ||
} // check if the text length matches | ||
$text = preg_replace('/[0-9]+/', '', $text); // remove all the numbers | ||
|
||
for ($i = 0; $i < strlen($text); $i++) { | ||
$index = strripos($alphabet, $text[$i]); | ||
if ($text[$i] == " ") { | ||
$cipherText .= " "; | ||
} else { | ||
$cipherText .= ( ctype_upper($text[$i]) ? strtoupper($key[$index]) : $key[$index] ); | ||
} | ||
} | ||
return $cipherText; | ||
} | ||
|
||
function maEncrypt($key, $alphabet, $text) | ||
{ | ||
return monoAlphabeticCipher($key, $alphabet, $text); | ||
} | ||
|
||
function maDecrypt($key, $alphabet, $text) | ||
{ | ||
return monoAlphabeticCipher($alphabet, $key, $text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.