Trying to create an encryption method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to create this encryption method for puzzles (nothing super
secret, just those cryptograms), but this seems to time out, can anybody
point out what I'm doing wrong here:

for ($i=1;$i<=26;$i++) {
            $normalAlphabet[$i] = chr($i);
        }
        //now, to shuffle

        for ($j=1;$j<=26;$j++) {
            do {
            $k = rand(1,26);
            } while ($k == $j || (strlen(trim($normalAlphabet[$k])) === 0));
            $arEncryptedAlphabet[$j] = $normalAlphabet[$k];
            $normalAlphabet[$k] = "";
        }
        $arNormalString = str_split($normalzedString);
        $encryptedString = "";
        for ($i=0;$i<count($arNormalString);$i++) {
            if (ord($arNormalString[$i])>=65 &&
ord($arNormalString[$i])<=90) {
                $encryptedString = $encryptedString .
$arEncryptedAlphabet[ord($arNormalString[$i]) - 64];
            } else {
                $encryptedString = $encryptedString . $arNormalString[$i];
            }
        }
        return $encryptedString;
    }

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux