{"id":19217068,"url":"https://github.com/8ctopus/byte-buffer","last_synced_at":"2026-01-05T03:07:17.264Z","repository":{"id":57678716,"uuid":"491370038","full_name":"8ctopus/byte-buffer","owner":"8ctopus","description":"php binary data buffer","archived":false,"fork":false,"pushed_at":"2024-07-26T14:29:39.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T10:31:42.563Z","etag":null,"topics":["binary","buffer","byte","hexadecimal","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/8ctopus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-12T05:00:17.000Z","updated_at":"2024-07-26T14:29:42.000Z","dependencies_parsed_at":"2024-07-26T16:02:06.653Z","dependency_job_id":null,"html_url":"https://github.com/8ctopus/byte-buffer","commit_stats":{"total_commits":130,"total_committers":2,"mean_commits":65.0,"dds":0.05384615384615388,"last_synced_commit":"45e3a643d4c1c032d62695d482985407c2b8ce60"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8ctopus%2Fbyte-buffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8ctopus%2Fbyte-buffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8ctopus%2Fbyte-buffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8ctopus%2Fbyte-buffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/8ctopus","download_url":"https://codeload.github.com/8ctopus/byte-buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244656074,"owners_count":20488635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","buffer","byte","hexadecimal","php"],"created_at":"2024-11-09T14:20:00.539Z","updated_at":"2026-01-05T03:07:17.192Z","avatar_url":"https://github.com/8ctopus.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# byte buffer\n\n[![packagist](https://poser.pugx.org/8ctopus/byte-buffer/v)](https://packagist.org/packages/8ctopus/byte-buffer)\n[![downloads](https://poser.pugx.org/8ctopus/byte-buffer/downloads)](https://packagist.org/packages/8ctopus/byte-buffer)\n[![min php version](https://poser.pugx.org/8ctopus/byte-buffer/require/php)](https://packagist.org/packages/8ctopus/byte-buffer)\n[![license](https://poser.pugx.org/8ctopus/byte-buffer/license)](https://packagist.org/packages/8ctopus/byte-buffer)\n[![tests](https://github.com/8ctopus/byte-buffer/actions/workflows/tests.yml/badge.svg)](https://github.com/8ctopus/byte-buffer/actions/workflows/tests.yml)\n![code coverage badge](https://raw.githubusercontent.com/8ctopus/byte-buffer/image-data/coverage.svg)\n![lines of code](https://raw.githubusercontent.com/8ctopus/byte-buffer/image-data/lines.svg)\n\nA php buffer to work with binary data.\n\n## install\n\n    composer require 8ctopus/byte-buffer\n\n## demo\n\n```php\nuse Oct8pus\\ByteBuffer\\ByteBuffer;\nuse Oct8pus\\ByteBuffer\\Endian;\nuse Oct8pus\\ByteBuffer\\Origin;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\necho \"Let's create a new little endian buffer and write string Hello World\\n\";\n\n$buffer = (new ByteBuffer())\n    -\u003esetEndian(Endian::LittleEndian)\n    -\u003ewriteString('Hello World');\n\necho $buffer . \"\\n\";\n// hex (12/12): 48656c6c 6f20576f 726c6400 - Hello World.\n\necho \"Add byte 0x07, word 0xFFFF and dword 0xAABBCCDD\\n\";\n\n$buffer\n    -\u003ewriteByte(0x07)\n    -\u003ewriteWord(0xFFFF)\n    -\u003ewriteDword(0xAABBCCDD);\n\necho $buffer;\n// hex (19/19): 48656c6c 6f20576f 726c6400 07ffffdd ccbbaa - Hello World........\n\necho \"\\nSeek buffer back to origin\\n\";\n\n$buffer-\u003eseek(0, Origin::Start);\n\necho $buffer;\n// hex (0/19): 48656c6c 6f20576f 726c6400 07ffffdd ccbbaa - Hello World........\n\necho \"\\nRead string from buffer\\n\";\n\necho $buffer-\u003ereadString() . \"\\n\";\n// Hello World\n\necho \"\\nRead byte, word and dword\\n\";\n\nprintf(\"0x%02X\\n\", $buffer-\u003ereadByte());\nprintf(\"0x%04X\\n\", $buffer-\u003ereadword());\nprintf(\"0x%08X\\n\", $buffer-\u003ereadDword());\n// 0x07\n// 0xFFFF\n// 0xAABBCCDD\n\necho \"\\nDelete World from buffer\\n\";\n\n$buffer-\u003edelete(6, 5);\n\necho $buffer;\n// hex (19/14): 48656c6c 6f200007 ffffddcc bbaa - Hello ........\n\necho \"\\nCalculate buffer crc32b\\n\";\n\necho '0x'. strtoupper($buffer-\u003ecrc32b(true)) . \"\\n\";\n// 0xF3B2604E\n\necho \"\\nInsert Parrot at position 6\\n\";\n\n$buffer\n    -\u003eseek(6, Origin::Start)\n    -\u003einsertChars('Parrot');\n\necho $buffer;\n// hex (12/20): 48656c6c 6f205061 72726f74 0007ffff ddccbbaa - Hello Parrot........\n\necho \"\\nCopy Parrot to a new buffer\\n\";\n\n$parrot = $buffer-\u003ecopy(6, 6);\n\necho $parrot;\n// hex (0/6): 50617272 6f74 - Parrot\n\necho \"\\nInvert Parrot\\n\";\n\necho $parrot-\u003einvert();\n// hex (0/6): 746f7272 6150 - torraP\n\necho \"\\nCalculate hashes\\n\";\necho 'md5: ' . $parrot-\u003emd5(false) . \"\\n\";\necho 'sha1: ' . $parrot-\u003esha1(false) . \"\\n\";\necho 'sha256: ' . $parrot-\u003esha256(false) . \"\\n\";\n// md5: 4264ed2a05f9548fb3b26601c1c904c4\n// sha1: d50da4682cdb41c803075168f5c132fd33ffa34d\n// sha256: e2d6ddb19ca9c3396521297f4a09581c1187acb29931c8d4431941be71d2215c\n\necho \"\\nTruncate buffer\\n\";\n\necho $parrot-\u003etruncate();\n// hex (0/0):\n```\n\n## run tests\n\n    composer test\n\n## clean code\n\n    composer fix\n    composer fix-risky\n\n# reference\n\n[https://igor.io/2012/09/24/binary-parsing.html](https://igor.io/2012/09/24/binary-parsing.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F8ctopus%2Fbyte-buffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F8ctopus%2Fbyte-buffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F8ctopus%2Fbyte-buffer/lists"}