[jdev] MD5

Matthias Wimmer m at tthias.net
Fri Apr 30 09:32:24 CDT 2004


Hi Remy!

Remy HAREL schrieb am 2004-04-30 15:52:44:
>   I'm looking for a function that would return a MD5 word on 128 bits 
> encryption based on a char* that would be given in argument, just 
> something like :

I don't know what you want to do. But I want to suggest that in most
cases you should use SHA-1 or some other bigger hash function than MD5.

>  (char * ) md5function(char * arg1 )

/* needed variables */
md5_state_t temp;
md5_byte_t result[16]);

/* the md5 calls */
md5_init(&temp);
md5_append(&temp, arg1, strlen(arg1));
md5_finish(&temp, result);

... the result is now in result ... but it's binary! You might convert
it to base64 or hex ... that's up to you and what you want the digest
for.



Tot kijk
    Matthias
-- 
Fon: +49-(0)70 0770 07770       http://matthias.wimmer.name/
HAM: DB1MW                      xmpp:mawis at charente.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://www.jabber.org/jdev/attachments/20040430/45ad0e00/attachment-0002.pgp>


More information about the JDev mailing list