Mailing List Archive

Hexa format
Hello, i'm a new user of the gcrypt library. It is a really great
library with really lots of feature. So thank you for you job !

I've just a simple question for you, i would like to know if there is
a function inside the gcrypt library to convert digest buffer to a
hexa string representation. In fact, i'm using the gcry_md_hash_buffer
function and i want to display on the screen the hexa representation
of the digest buffer.

I've got another question, i want to know what it is more efficient:
- use the gcry_md_hash_buffer function
- or use the set of functions:
- gcry_md_write
- gcry_md_read

Thank you !

I've you can send me the email to my box because i've not subcribed to the ML

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: Hexa format [ In reply to ]
On Monday 30 January 2006 09:46 am, joel vennin wrote:
> I've just a simple question for you, i would like to know if there is
> a function inside the gcrypt library to convert digest buffer to a
> hexa string representation. In fact, i'm using the gcry_md_hash_buffer
> function and i want to display on the screen the hexa representation
> of the digest buffer.
There is some code in src/sexp.c that does this (look at convert_to_hex()),
but it is trivial to write your own.

> I've got another question, i want to know what it is more efficient:
> - use the gcry_md_hash_buffer function
> - or use the set of functions:
> - gcry_md_write
> - gcry_md_read
For SHA1 and RMD160, gcry_md_hash_buffer will probably be faster. Otherwise it
probably isn't going to make much difference, although it does depend on your
exact setup (where the data comes from, costs of caching, memory limits). If
it is really important, do both and time it.

BTW: You could have read the code in cipher/md.c - that is all I did.
Brad
Re: Hexa format [ In reply to ]
On Sun, 29 Jan 2006 23:46:18 +0100, joel vennin said:

> hexa string representation. In fact, i'm using the gcry_md_hash_buffer
> function and i want to display on the screen the hexa representation
> of the digest buffer.

No, there is no such function.

> I've got another question, i want to know what it is more efficient:
> - use the gcry_md_hash_buffer function
> - or use the set of functions:
> - gcry_md_write
> - gcry_md_read

That depends. If you need to hash a string you are already holding
entirely and as one chunk in memory, gcry_md_hash_buffer is a bit more
effcient. You should use this function only if you can hard wire the
digest algorithm (like SHA1) because the fucntion will abort the
process in case of an unknown digest algorithm.


Salam-Shalom,

Werner


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel