Example #1
0
            $shift = $index + $sh;
            while ($shift > $n - 1) {
                $shift -= $n;
            }
            return $arr[$shift];
        } else {
            if ($arr2[$i] == $char) {
                $index = $i;
                $shift = $index + $sh;
                while ($shift > $n - 1) {
                    $shift -= $n;
                }
                return $arr2[$shift];
            }
        }
    }
    if ($index == -1) {
        return $char;
    }
}
function encrypt_message($str, $sh)
{
    $length = strlen($str);
    for ($i = 0; $i < $length; $i++) {
        $res[$i] = shift($str[$i], $sh);
    }
    $tmp['result'] = implode($res);
    echo json_encode($tmp);
}
encrypt_message($tmp['source'], $tmp['shift']);
Example #2
0
5. To clean the key contacts, all keys (II, 6) are to be pressed down firmly multiple times, and let snap back 
rapidly. While doing this, one key is to be held down to avoid unnecessary progression of the cylinders.

6. The battery switch (II, 7) is to be set to „dunkel" (dark) when the battery is fresh. As soon as the battery 
voltage degrades after long use, the setting „hell" (light) is to be used for improved brightness of the bulbs. 
Using the setting „hell" too early will lead to premature bulb burn out.

7. In bright sunshine, and to spare the user’s eyes, it is advisable to remove the green Zellon panel (I/II, 8) 
from the wooden cover by lifting and turning the spring-loaded buttons (I/II, 9), and to secure it on top of the 
transparent letters using the same mechanism. The Zellon panel attenuates the light of the bulbs and covers all 
letters so that only the lit letter is visible.

8. For protection against bright sunlight the device can be shaded through pulling the joints of the cover 
hinge (II, 14) out towards the front, and closing the wooden cover down partially.

9. There is a sheet holder (I, 42) on the inside of the wooden cover that allows documents to be held 
comfortably in front of the operators eyes during encryption.

 

END_PLAIN;
echo '<pre>';
echo "Starting Plaintext:\n{$plaintext}";
echo "\n --- \n";
$ciphertext = encrypt_message($plaintext, $public_key);
echo "\nCiphertext:\n";
echo chunk_split($ciphertext);
$plaintext2 = decrypt_message($ciphertext, $private_key);
echo "\n\nDecrypted Back into Plaintext\n\n";
echo $plaintext;
Example #3
0
                $shift += $n;
            }
            return $arr[$shift];
        } else {
            if ($arr2[$i] == $char) {
                $index = $i;
                $shift = $index - $sh;
                while ($shift < 0) {
                    $shift += $n;
                }
                return $arr2[$shift];
            }
        }
    }
    if ($index == -1) {
        return $char;
    }
}
function encrypt_message($str)
{
    $sh = getFrequencyShift($str);
    $length = strlen($str);
    for ($i = 0; $i < $length; $i++) {
        $res[$i] = shift($str[$i], $sh);
    }
    $tmp['result'] = implode($res);
    $tmp['shift'] = $sh;
    echo json_encode($tmp);
}
encrypt_message($tmp['source']);