tags:

views:

108

answers:

3

Possible Duplicate:
In C++, How to get MD5 hash of a file?

I am currently using Ubuntu and am wishing to calculate the MD5 of a char*. was wondering if there is a pre-installed library that would just need including, or would I have to download a specially designed one?

A: 

Have a look at hashlib++ or Crypto API.

Exa
A: 

I would rephrase the question. In the context of C++, you're asking for the MD5 sum of a single pointer to char, which is practically meaningless.

That 'char *' could refer to a location in memory that refers to the file content you are after, in which case you're going to need a size somewhere, or it could refer to a null-terminated string, or a pascal-string, or, really, anything else.

With ubuntu, I'd do something like 'apt-cache search md5' and see what you get. On my debian system, libgcrypt11 looks intruging.

Arafangion
Most C/C++ programmers understand that normally char * refers to a NULL terminated string. It could mean other things but no need to be so pedantic.
bradgonesurfing
Actually, in C++, it probably more often refers to an arbituary chunk of memory - a 'char' being used as a generic byte type. One would normally use std::string instead. This is C++, not C.
Arafangion
And don't forget, I actually show how to find this information yourself, ie, make use of the package manager - AND, I give a promising result that could be useful.
Arafangion
+3  A: 

Include openssl/MD5.h and use the following to calculate the hash

MD5(<characters>, <length of it>, <the result(pointer)>);
Lee