Exemple #1
0
    }
    if ($mode === "encrypt") {
        //get 64 bit encrypted data:
        $enc_data = Encrypt(Decrypt(Encrypt($data, $key_Ks1), $key_Ks2), $key_Ks3);
        //64 to dec and dec to hex:
        $dec_enc_data = ArrayToDec($enc_data);
        $hex_enc_data = DecToHex($dec_enc_data);
        echo "<br />";
        echo "encription result:<br />";
        test($hex_enc_data, 1);
    } elseif ($mode === "decrypt") {
        //get 64 bit decrypted data:
        $dec_data = Decrypt(Encrypt(Decrypt($data, $key_Ks3), $key_Ks2), $key_Ks1);
        //64 to dec and dec to hex:
        $dec_dec_data = ArrayToDec($dec_data);
        $hex_dec_data = DecToHex($dec_dec_data);
        echo "<br />";
        echo "decription result:<br />";
        test($hex_dec_data, 1);
    }
}
//end if
?>
        </div>
    </body>
    <script>
        function SameToKey1() {
            var key1 = document.getElementsByName("key1[]");
            var key3 = document.getElementsByName("key3[]");
            for (var i = 0; i < 8; i++) {
                key3[i].value = key1[i].value;
Exemple #2
0
<?php

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