[mythtv] LastFM support in MythMusic

Anduin Withers awithers at anduin.com
Tue Feb 26 18:32:25 UTC 2008

> 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()),
    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 

More information about the mythtv-dev mailing list