"Sputnik" help  
Sputnik Help
BinaryToHex(<binary>, [<separator>])


Converts a binary string to its hexadecimal representation. Each byte in the binary string is converted to a pair of hexadecimal digits. The resulting hexadecimal string will be in uppercase. Optionally, you can specify a <separator> character to separate each pair of hexadecimal digits.


<binary> The binary string to be converted to hexadecimal.
<separator> Optional separator character to be inserted between each pair of hexadecimal digits. (Default: Empty String)

Return Value

Success: Returns hexadecimal string representing the hexadecimal representation of the binary string..
Failure: Returns empty string.


The BinaryToHex function offers a convenient way to convert binary data to its hexadecimal representation. Hexadecimal representation is commonly used for encoding binary data during transmission or storage. The resulting hexadecimal string provides a human-readable and compact representation of the original binary data, making it useful for debugging, data visualization, and interoperability purposes. Additionally, you can optionally specify a <separator> character to insert between each pair of hexadecimal digits, improving readability and facilitating data analysis.




Example of usage:

my $hex = BinaryToHex(bin("Hello world!"));
say $hex;
my $bin = BinaryFromHex($hex);
say BinaryExpand($bin, false);

my $hex = BinaryToHex(bin("Hello world!"), "-");
say $hex;
my $bin = BinaryFromHex($hex, "-");
say BinaryExpand($bin, false);

// 48656C6C6F20776F726C6421
// 48 65 6C 6C 6F 20 77 6F 72 6C 64 21 -- -- -- -- Hello world!
// 48-65-6C-6C-6F-20-77-6F-72-6C-64-21
// 48 65 6C 6C 6F 20 77 6F 72 6C 64 21 -- -- -- -- Hello world!


Cheryl (uberfox@hotmail.com)