Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,19 @@
<?php
function caesarEncode( $message, $key ){
$plaintext = strtolower( $message );
$ciphertext = "";
$ascii_a = ord( 'a' );
$ascii_z = ord( 'z' );
while( strlen( $plaintext ) ){
$char = ord( $plaintext );
if( $char >= $ascii_a && $char <= $ascii_z ){
$char = ( ( $key + $char - $ascii_a ) % 26 ) + $ascii_a;
}
$plaintext = substr( $plaintext, 1 );
$ciphertext .= chr( $char );
}
return $ciphertext;
}
echo caesarEncode( "The quick brown fox Jumped over the lazy Dog", 12 ), "\n";
?>

View file

@ -0,0 +1,9 @@
<?php
function caesarEncode($message, $key) {
$from = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$to = substr($from, $key) . substr($from, 0, $key);
return strtr($message, $from, $to);
}
echo caesarEncode('THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG', 12), PHP_EOL;