Oihana PHP

hexEncode.php

Table of Contents

Functions

hexEncode()  : string
Encodes binary data into a lowercase hexadecimal string.

Functions

hexEncode()

Encodes binary data into a lowercase hexadecimal string.

hexEncode(string $binary) : string

Thin wrapper around bin2hex() provided for API symmetry with the other helpers of this package (hexDecode(), base64UrlEncode()).

The function is binary-safe and always produces lowercase output, which matches the convention used for hashes, tokens and HMAC tags across the Oihana ecosystem.

Parameters
$binary : string

Raw bytes to encode. May be empty.

Tags
example
use function oihana\core\encoding\hexEncode;

echo hexEncode( 'abc' ) ;        // "616263"
echo hexEncode( "\x00\xFF" ) ;   // "00ff"
echo hexEncode( '' ) ;           // ""
see
hexDecode()

For the inverse operation.

author

Marc Alcaraz (ekameleon)

since
1.0.8
Return values
string

A string of [0-9a-f] characters, twice as long as $binary.

On this page

Search results