hex conversion
Max
maxim.suraev at campus.tu-berlin.de
Thu Dec 18 17:06:18 CET 2014
Hi all.
After some basic experimentation with libgcrypt and reading through API docs it seems
like just the thing I need. However one utility piece seems to be missing -
conversion to and from hexadecimal strings.
For example I receive data as a command-line argument, calculate hash from it and
print it onto the screen:
./a.out 39ef13c5aaaaaaaaaaaaaaaaa
test hash: 2b567dd47b587955f1a83f60f94138ad
I can use gcry_md_hash_buffer(...) but first I've got to prepare buffer, so I need to
convert ascii string "39ef13c5aaaaaaaaaaaaaaaaa" into hexadecimal uint8_t * buffer.
Similarly, I've got to convert resulting digest into proper ascii representation.
Am I missing something obvious or every user of libgcrypt writes its own hex2bin()
and bin2hex() functions?
best regards,
Max.
More information about the Gcrypt-devel
mailing list