This language bar is your friend. Select your favorite languages!

Idiom #175 Bytes to hex string

From array a of n bytes, build the equivalent hex string s of 2n digits.
Each byte (256 possible values) is encoded as two hexadecimal characters (16 possible values per digit).

use hex::ToHex;
let mut s = String::with_capactiy(2 * a.len());
a.write_hex(&mut s).expect("Failed to write");
import std.digest;
s = a.toHexString;
import "encoding/hex"
s := hex.EncodeToString(a)
sysutils
s := '';
for b in a do s := s + IntToHex(b,2);
s = a.hex()
s = a.unpack("H*")

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org

Related idioms