C + + implementation of Crypto.md5file () in Quick-cocos2d-x 2.2.3 RC version has bugs on Android

Source: Internet
Author: User

The original version is opened with fopen file, if you want to take the files from the Android apk, directly washed white
Modify the following


void Cccrypto::md5file (const char* path, unsigned char* output)
{
unsigned long len = 0;
To make sure we can get data of the files easily from ios,android,pc etc.
We use Ccfileutils::sharedfileutils ()->getfiledata
unsigned char* pData = Ccfileutils::sharedfileutils ()->getfiledata (path, "R", &len);
if (PData = = NULL | | len = = 0) {
Cclog ("Cccrypto::md5file () can ' t open file%s", path);
Return
}

Md5_ctx CTX;
Md5_init (&CTX);


Md5_update (&ctx, PData, Len);
Md5_final (output, &ctx);


Delete data as ccfileutils::sharedfileutils ()->getfiledata claimed.
if (pData! = NULL)
Delete[] PData;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.