saya ada problem mengenai proses deskripsi file dengan metode caesar cipher. Saya sudah mencoba deskripsi file txt yang isinya dengan kata pendek alhamdulillah bisa, tapi ketika saya coba mendeskripsi file txt yang isinya lebih panjang dari sebelumnya hasil deskripsinya error tidak karuan. apa ada salah dengan script saya ?
SCRIPT DESKRIPSI CAESAR CIPHER
function caesarCipher($strText, $iShiftValue) {
$strCipherText = "";
$iShift = $iShiftValue % 26;
if ($iShift < 0)
$iShift += 26;
$i = 0;
while ($i < strlen($strText)) {
$c = strtoupper($strText{$i});
if ( ($c >= "A") && ($c <= 'Z')) {
if ( (ord($c) - $iShift) > ord("Z") )
$strCipherText .= chr(ord($c) - $iShift - 26);
else
$strCipherText .= chr(ord($c) - $iShift);
}
else
$strCipherText .= " ";
$i++;
}
return $strCipherText . "\n";
}
SCRIPT ENKRIPSI CAESAR CIPHER
function caesarCipher($strText, $iShiftValue) {
$strCipherText = "";
$iShift = $iShiftValue % 26;
if ($iShift < 0)
$iShift += 26;
$i = 0;
while ($i < strlen($strText)) {
$c = strtoupper($strText{$i});
if ( ($c >= "A") && ($c <= 'Z')) {
if ( (ord($c) + $iShift) > ord("Z") )
$strCipherText .= chr(ord($c) + $iShift - 26);
else
$strCipherText .= chr(ord($c) + $iShift);
}
else
$strCipherText .= " ";
$i++;
}
return $strCipherText . "\n";
}
0 jempol