mracine/php-binary-string

Library to manipulate binary strings

v0.2 2023-05-22 08:59 UTC

This package is auto-updated.

Last update: 2024-04-22 11:12:02 UTC


README

Latest Stable Version PHP 7 ready License Travis Build Status Scrutinizer Build Status Scrutinizer Code Quality Code Coverage Code Intelligence Status Maintainability

PHP BINARY STRING HELPER

mracine\Helpers\BinaryStringHelper is a library that provide tools to manipulate binary strings with PHP.

Installation

You can add this library as a local, per-project dependency to your project using Composer:

composer require mracine/php-binary-string

Usage

The mracine\Helpers\BinaryStringHelper is a class that provide one method :

  • IntegerToNBOBinaryString static method : takes one integer parameter and returns a Network byte ordered trimed string
<?php
use mracine\Helpers\BinaryStringHelper;

//   0xFF7 => chr(0x0F).chr(0xF7)
//   0x12345678 => chr(0x12).chr(0x34).chr(0x56).chr(0x76)

// Compatible with all xx bits systems (16, 32 ...) 

$networkReadyString =  BinaryStringHelper::IntegerToNBOBinaryString(123456789);
// $network ready string contains chr(0x7).chr(0x5B).chr(0xCD).chr(0x15)
$networkReadyString =  BinaryStringHelper::IntegerToNBOBinaryString(0x12345);
// $network ready string contains chr(0x1).chr(0x23).chr(0x45)