Hi again.
I'd like to make simple crypter by myself, this is what I've done so far:
So basically, it is supposed to replace the characters in the $notcrypted1 with the key-table's corresponding int value.
But the problem is, that I'd like to know if there's any way to tell the program to switch the character it is going trought with the key-table's corresponding int value ... And like without doing 3000 if's.
Since it can replace the vowels with blank in the example - is it possible to switch the characters with the ints in my code?
My brains are jamming with this one ... I know it will not work like this and I even know why it isn't working - I just can't find a way to solve it ...
I wouldn't want to do it like so:
I'd like to make simple crypter by myself, this is what I've done so far:
Code: (php)
//This is the key-table for crypter.
$cryptkey = array('0' => 286, '1' => 949, '2' => 695, '3' => 348, '4' => 438, '5' => 977,
'6' => 320, '7' => 418, '8' => 970, '9' => 482, '[' => 466, ']' => 770, '.' => 569,
' ' => 242, '-' => 166, 'A' => 583, 'B' => 575, 'C' => 247, 'D' => 564, 'E' => 192,
'F' => 513, 'G' => 653, 'H' => 605, 'I' => 450, 'J' => 404, 'K' => 831, 'L' => 315, 'M' => 953,
'N' => 439, 'O' => 266, 'P' => 231, 'Q' => 633, 'R' => 881, 'S' => 113, 'T' => 935, 'U' => 559,
'V' => 318, 'W' => 927, 'X' => 906, 'Y' => 463, 'Z' => 184, 'a' => 263, 'b' => 453, 'c' => 208,
'd' => 591, 'e' => 511, 'f' => 343, 'g' => 969, 'h' => 415, 'i' => 420, 'j' => 175, 'k' => 410,
'l' => 295, 'm' => 265, 'n' => 877, 'o' => 200, 'p' => 837, 'q' => 913, 'r' => 515, 's' => 262,
't' => 524, 'u' => 874, 'v' => 525, 'w' => 700, 'x' => 670, 'y' => 918, 'z' => 290, '<' => 331,
'>' => 533, "'" => 425, ',' => 101, ':' => 495, '$' => 114, '\\' => 268, '/' => 721, '=' => 454);
//Don't mind about some fails in the table ... solving them later.
//This is the string we're going to crypt.
$notcrypted1 = "[$curdate] - Rotation was <font color = '$color'><b>$rotation</b></font> degrees, done by <b>$ip</b>, who says: ''<b>$msg</b>''\r\n";
//Splitting the string here. (is this even needed?)
$split1 = str_split($notcrypted1);
//And this is the problem area
foreach ($split1 as $char) {
foreach ($cryptkey as $char2 => $key2) {
$crypted1 = str_replace($char, $key2, $notcrypted1);
}
}
//Im using this PHP.net's example
// Provides: Hll Wrld f PHP
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");So basically, it is supposed to replace the characters in the $notcrypted1 with the key-table's corresponding int value.
But the problem is, that I'd like to know if there's any way to tell the program to switch the character it is going trought with the key-table's corresponding int value ... And like without doing 3000 if's.
Since it can replace the vowels with blank in the example - is it possible to switch the characters with the ints in my code?
My brains are jamming with this one ... I know it will not work like this and I even know why it isn't working - I just can't find a way to solve it ...
I wouldn't want to do it like so:
Code: (php)
foreach ($split1 as $char) {
foreach ($cryptkey as $char2 => $key2) {
if ($char == "A") {
$crypted1 = str_replace($char, "A", $notcrypted1);
}
}







Therefore this workaround.