Пример #1
0
function S_box(&$temp_B)
{
    global $box_S;
    $m = $n = 0;
    for ($j = 0; $j < 8; $j++) {
        $m = $temp_B[$j][0] * 2 + $temp_B[$j][5];
        $n = $temp_B[$j][1] * 2 * 2 * 2 + $temp_B[$j][2] * 2 * 2 + $temp_B[$j][3] * 2 + $temp_B[$j][4];
        $temp_B[$j] = BinToArray(DecToBin($box_S[$j][$m][$n]));
    }
}
Пример #2
0
<?php

/**
 * Write a string function DecToBin(N) that returns a string containing the binary representation of a
 * nonnegative integer N. The string consists of characters "0", "1" and does not contain leading zeros
 * (except for the representation of zero number). Using this function, output binary representations of
 * five given integers.
 */
include 'helper.php';
function DecToBin($N)
{
    echo decbin($N) . '<br/>';
}
DecToBin(65535);
DecToBin(255);
DecToBin(127);