Skip to content

Add hex encoding and decoding (to_hex / from_hex) #35

@davidgaspardev

Description

@davidgaspardev

Description

Implement functions to encode raw bytes to hexadecimal string representation and decode them back.

// {0x48, 0x69} → "4869"
byte_t to_hex(cbytes_t src, unsigned int src_len, bytes_t dst, unsigned long sizeof_dst);

// "4869" → {0x48, 0x69}
byte_t from_hex(cbytes_t hex, bytes_t dst, unsigned long sizeof_dst);

Use cases

  • Debug output of binary buffers
  • Network protocol inspection
  • Cryptographic hash display (MD5, SHA digests)

References

  • Encoding: Hexadecimal (Base-16)
  • Standard: Each byte is represented as two hex digits (nibbles)
  • Wikipedia: Hexadecimal
  • Related: xxd, hexdump Unix tools

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions