Exemple #1
0
function ivcs_transform_to($hex)
{
    global $ivcs;
    $boolArr = hexString_2_booleanArray($hex);
    // Convert Hex input to an array of 1's and 0's
    $boolArr = array_merge($boolArr, rfc2289_checksum($boolArr));
    // append checksum to form 66 bit array
    for ($i = 0; $i < 6; $i++) {
        $arrSlice = array_slice($boolArr, $i * 11, 11);
        // extract the 11 bits that we want
        $index = binstr2int(implode($arrSlice));
        // create an integer index from the bits
        $word[$i] = $ivcs[$index];
        // look up the code word
    }
    return $word;
}
Exemple #2
0
function randomBooleanArray($numBits)
{
    $bytesString = randomBytes($numBits);
    $hexString = bin2Hex($bytesString);
    $booleanArray = hexString_2_booleanArray($hexString);
    return array_slice($booleanArray, 0, $numBits);
}