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).

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

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

Idiom created by

Related idioms