gnutls_hex2bin(3)

πŸ’– gnutls_hex2bin(3) πŸ’–

okay bestie, sit down, hydrate, and let me tell you about this lil function from the gnutls manual. she's giving ✨hex-to-binary✨ and she's honestly so underrated.


🌸 NAME 🌸

gnutls_hex2bin β€” it's an API function, no cap πŸ’…


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

int gnutls_hex2bin(const char * hex_data, size_t hex_size, void *
bin_data, size_t * bin_size);

like, that's it. that's the whole vibe. πŸ¦‹


πŸŽ€ ARGUMENTS πŸŽ€

  • const char * hex_data β€” a string holding your data in hex format. the raw material, the main character, the moment fr.
  • size_t hex_size β€” how big that hex data is. gotta tell her the size, she's not a mind reader πŸ™ˆ
  • void * bin_data β€” the output array where the binary data lands. your lil container for the glow-up.
  • size_t * bin_size β€” okay so this one is doing double duty and honestly? iconic. when you call, it should hold the maximum size of bin_data. on return, it holds the actual length of bin_data. she reads your intentions, then tells you what actually happened. periodt. πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

Convert a buffer with hex data to binary data. that's the whole job, and she does it beautifully. 🌈

but here's the tea β˜•: unlike gnutls_hex_decode(), this function can parse hex data that has separators between numbers. that's right β€” she ignores any non-hex characters. colons, dashes, spaces, whatever weird little punctuation you threw in there? she doesn't even see them. not me being unbothered by your formatting choices πŸ’…βœ¨

so if your hex is all gussied up with separators, this is your girl. gnutls_hex_decode() could never, lowkey.


🫢 RETURNS 🫢

GNUTLS_E_SUCCESS on success β€” slay! πŸŽ‰

otherwise, a negative error code. so like, check your return values, bestie, don't just assume it ate. 😭


πŸ¦‹ SINCE πŸ¦‹

2.4.0 β€” she's been here since 2.4.0, an OG, a legend, a founding mother of the API. πŸ‘‘


πŸ’€ REPORTING BUGS πŸ’€

found a bug? not the vibe, but okay, let's handle it:

Report bugs to <bugs@gnutls.org>.

Home page: https://www.gnutls.org

fr fr, if something's broken, tell the maintainers. they want to know. communication is key in every relationship, including the one between you and your crypto library. πŸ’–

Copyright Β© 2001-2023 Free Software Foundation, Inc., and others.

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.

so like, you can copy it, share it, remix it β€” just keep the copyright notice and this notice with it. give credit where credit is due, always. 🌸

πŸ”₯ SEE ALSO πŸ”₯

The full documentation for gnutls is maintained as a Texinfo manual. If the /usr/share/doc/gnutls/ directory does not contain the HTML form, visit:

https://www.gnutls.org/manual/

like, the whole lore is right there, go read it, iykyk πŸ“šβœ¨


and that's the page, bestie!! this one came from gnutls 3.8.13, and you'll find it filed under gnutls_hex2bin(3) in the manual. mwah πŸ’‹ go convert some hex, you gorgeous nerd. πŸ§šπŸ’œ

πŸ“¦ where this page comes from