Last active
January 26, 2020 13:42
-
-
Save timmyRS/2a5281e7e663e27269c7a38e076cf9c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Phpcraft; | |
require "vendor/autoload.php"; | |
$bits_per_block = 5; | |
$bits = ""; | |
foreach([1, 2, 2, 3, 4, 4, 5, 6, 6, 4, 8, 0, 7, 4, 3, 13, 15, 16, 9, 14, 10, 12, 0, 2, 11, 4] as $value) | |
{ | |
$bits .= strrev(str_pad(decbin($value), $bits_per_block, "0", STR_PAD_LEFT)); | |
} | |
$data = new Connection(); | |
for($i = 0; $i < 2; $i++) | |
{ | |
$data->writeGMP(gmp_init(strrev(substr($bits, $i * 64, 64)), 2), 8, 64, false, GMP_LSW_FIRST | GMP_BIG_ENDIAN); | |
} | |
echo Phpcraft::binaryStringToHex(substr($data->write_buffer, 0, 8))." = ".Phpcraft::binaryStringToBin(substr($data->write_buffer, 0, 8))."\n"; | |
echo Phpcraft::binaryStringToHex(substr($data->write_buffer, 8, 8))." = ".Phpcraft::binaryStringToBin(substr($data->write_buffer, 8, 8))."\n"; | |
// 70 20 86 31 48 41 88 41 = 01110000 00100000 10000110 00110001 01001000 01000001 10001000 01000001 | |
// 8b 10 18 a7 26 0f 68 c8 = 10001011 00010000 00011000 10100111 00100110 00001111 01101000 11001000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"craft/core": "^0.5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment