Android ndk MD5哈希函数字符串转换

时间:2014-04-02 08:58:51

标签: c++ android-ndk

您好我想尝试将md5 hash c ++函数包含到我的Android NDK项目中。 我有类型的问题。 Eclipse显示我使用以下消息构建无效参数错误:

  

无效的参数'候选者是:void update(const unsigned char *,   unsigned int)void update(const char *,unsigned int)'

方法:

// nifty shortcut ctor, compute MD5 for string and finalize it right away
MD5::MD5(const std::string &text)
{
    init();
    update(text.c_str(), text.length()); //there is problem
    finalize();
}

我称这种方法为:

// MD5 block update operation. Continues an MD5 message-digest
// operation, processing another message block
void MD5::update(const char input[], size_type length)
{
    // compute number of bytes mod 64
    size_type index = count[0] / 8 % blocksize;

    // Update number of bits
    if ((count[0] += (length << 3)) < (length << 3))
        count[1]++;
    count[1] += (length >> 29);

    // number of bytes we need to fill in buffer
    size_type firstpart = 64 - index;

    size_type i;

    // transform as many times as possible.
    if (length >= firstpart)
    {
        // fill buffer first, transform
        memcpy(&buffer[index], input, firstpart);
        transform(buffer);

        // transform chunks of blocksize (64 bytes)
        for (i = firstpart; i + blocksize <= length; i += blocksize)
            transform(&input[i]);

        index = 0;
    }
    else
        i = 0;

    // buffer remaining input
    memcpy(&buffer[index], &input[i], length - i);
}

//////////////////////////////

// for convenience provide a verson with signed char
void MD5::update(const char input[], size_type length)
{
    update((const unsigned char*)input, length);
}

有什么问题,项目通常在Visual Studio中工作但在java NDK中我有这些问题... 谢谢你的帮助

0 个答案:

没有答案