Skip to content

encode

Encodes bytes as lowercase hexadecimal.

use helpers4::hex::encode;

Cargo feature hex (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features hex

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.5", default-features = false, features = ["hex"] }
pub fn encode(bytes: &[u8]) -> String
ParameterTypeDescription
bytes&[u8]The bytes to encode.

String

use helpers4::hex::encode;

assert_eq!(encode(&[0xde, 0xad, 0xbe, 0xef]), "deadbeef");
assert_eq!(encode(&[]), "");

src/hex/encode.rs