encode($bytes, $offset, $length); } /** * Encodes the given bytes into a base-16 string, inserting colons after every 2 characters of output. * * @static * @param array $bytes an array containing the bytes to encode * @param int $offset the start offset of the data within bytes * @param int $length the number of bytes to encode * @return string the base-16 string */ public static function encodeWithColons(array $bytes, $offset = null, $length = null) { return self::getInstance()->encode($bytes, $offset, $length, ':', 2); } /** * Encodes the given bytes into a base-16 string, inserting spaces after every 2 characters of output. * * @static * @param array $bytes an array containing the bytes to encode * @param int $offset the start offset of the data within bytes * @param int $length the number of bytes to encode * @return string the base-16 string */ public static function encodeWithSpaces(array $bytes, $offset = null, $length = null) { return self::getInstance()->encode($bytes, $offset, $length, ' ', 2); } /** * Decodes the given base-16 string into a byte array. * * @static * @param string $string base-16 encoded string * @return array array containing the decoded bytes */ public static function decode($string) { return self::getInstance()->decode($string); } /** * Gets singleton instance of GTBaseX configured for base-16 encoding/decoding. * * @static * @return GTBaseX singleton instance of GTBaseX */ private static function getInstance() { if (self::$instance == null) { self::$instance = new GTBaseX("0123456789ABCDEF", false, ' '); } return self::$instance; } } ?>