OK, well with the malloc in place, it now actually works.
I do not have a vector implementation, yet...
But I do know the encoding that should be used, namely utf8, I already
know how to convert the QString to utf8, so that is no problem.
But the thing I really want is a hexadecimal representation of that
binary data and cast that to a string, just like the normal md5sum
would do.
Any ideas on how to accomplish that?
I know casting won't work :)
Thanks,
Willem
On Tue, Feb 26, 2008 at 7:32 PM, Anduin Withers <awithers at anduin.com> wrote:
> > I have created an extra method:
> > uint8_t *my_md5(QString string)
> > {
> > uint8_t *md5val;
> > uint8_t *c_string = (uint8_t*)string.toUInt();
> > av_md5_sum(md5val, c_string, string.length());
> > return md5val;
> > }
> > [...]
> > cout << *test << endl;
>> You probably do not want to do that, it will output only the first byte, you
> definitely do not want to "cout << test", the returned data is 16 bytes of
> binary data, there is no null termination (and would be gibberish anyway).
>> Personally I'd return a std::vector<uint8_t>, you incur the tremendous cost
> of a copy but you don't need to remember to free()/delete.
>> std::vector<uint8_t> my_md5(const QString &s)
> {
> std::vector<uint8_t> md5val(16);
> QCString cs = s.utf8();
> av_md5_sum(&md5val[0], reinterpret_cast<const uint8_t *>(cs.data()),
> cs.length());
> return md5val;
> }
>> You should spend some time thinking about the encoding of the string. If you
> are comparing you need to ensure both sources agree on the encoding before
> the digest is generated.
>> --
> Anduin Withers
>>>> _______________________________________________
> mythtv-dev mailing list
>mythtv-dev at mythtv.org>http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev>