gnutls_hex_decode(3)

πŸ’– gnutls_hex_decode(3) β€” the gnutls girlies' guide πŸ’–

okay bestie, so this one's from the gnutls manual β€” yes, that gnutls β€” and it's a little cutie called gnutls_hex_decode. it does exactly one thing and it does it flawlessly. let's get into it 🫢


✨ NAME ✨

gnutls_hex_decode β€” literally just an API function, that's the whole vibe πŸ’…


🌸 SYNOPSIS 🌸

#include <gnutls/gnutls.h>

int gnutls_hex_decode(const gnutls_datum_t * hex_data, void * result,
size_t * result_size);

look at her. so demure. so mindful. πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • const gnutls_datum_t * hex_data β€” this is the encoded data, bestie. the hex-y stuff. the thing you're about to take apart ✨
  • void * result β€” this is where the decoded data gets copied to. her little home 🏠
  • size_t * result_size β€” this holds the size of the result. and ngl she's doing double duty, more on that below πŸ‘‡

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, okay? this function will decode the given encoded data, using the hex encoding used by PSK password files. that's the specific flavor of hex we're talking about, no substitutions πŸ”₯

now the part that trips people up, so pay attention pookie: initially result_size must hold the maximum size available in result. you gotta tell her how much room she's got to work with up front.

and then, on return, result_size will contain the number of bytes written. so she goes in holding a capacity and comes out holding a count. character development, honestly. 🌈


⭐ RETURNS ⭐

  • GNUTLS_E_SHORT_MEMORY_BUFFER β€” the buffer you gave her is not long enough. she's not mad, she's just disappointed 😭
  • GNUTLS_E_PARSING_ERROR β€” the hex data is invalid. it's giving "who wrote this" πŸ’€
  • 0 β€” success!! we love to see it, ate and left no crumbs πŸ‘‘

πŸ› REPORTING BUGS πŸ›

found something cursed? report bugs to <bugs@gnutls.org>. they wanna hear about it fr fr.

home page is right here: https://www.gnutls.org


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. (iconic behavior tbh β€” free and unbothered 🌸)


πŸ‘€ 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/


πŸ’‘ no cap: read the result_size bit twice. capacity in, byte-count out. that's the whole plot twist and it will get you if you skim. iykyk πŸ™ˆ

and that's the page, bestie!! πŸŽ€ this one shipped with gnutls 3.8.13, dated right there at the bottom next to gnutls_hex_decode(3) β€” so if you're running that version, you're literally holding the exact manual this was written from. slay. go decode something cute. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from