Re: Trying to create an encryption method
| From: | Stut | Date: | Sun, 05 Nov 2006 04:43:58 +0000 |
| Subject: | Re: Trying to create an encryption method | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244221@lists.php.net to get a copy of this message | ||
John Meyer wrote:
for ($i=1;$i<=26;$i++) {Both the inner loop and the outer loop are using $i, meaning the outer loop will never end since it gets reset in the inner loop. -Stut$normalAlphabet[$i] = chr($i); } //now, to shufflefor ($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; }