Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make md5 calcation base on ppsspp
07-31-2022, 02:02 AM
Post: #3
RE: Make md5 calcation base on ppsspp
Thanks [Unknown]
Next question:How to calculation first 262144 byte of md5 ?

Now the full file size of md5 calc of code is:
Code:
#include "Common/Crypto/md5.h"

static char hb2hex(unsigned char hb) {
    hb = hb & 0xF;
    return hb < 10 ? '0' + hb : hb - 10 + 'a';
}

std::string MD5FullFile(const Path filename) {
    FILE* in = File::OpenCFile(filename, "rb");
    if (!in) {
        WARN_LOG(COMMON, "Unable to open %s\n", filename.c_str());
        return "";
    }
    unsigned char buff[BUFSIZ];
    md5_context c;
    md5_starts(&c);
    unsigned char out[16];
    size_t len = 0;    
    while ((len = std::fread(buff, sizeof(char), BUFSIZ, in)) > 0) {
        md5_update(&c, buff, len);
    }
    md5_finish(&c, out);
    std::string res;
    for (size_t i = 0; i < 16; ++i) {
        res.push_back(hb2hex(out[i] >> 4));
        res.push_back(hb2hex(out[i]));
    }
    fclose(in);
    return res;
}
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Make md5 calcation base on ppsspp - sum2012 - 07-31-2022 02:02 AM

Forum Jump: