您的位置:首页 > 编程语言 > C语言/C++

c++进行文件摘要

2015-07-19 00:59 239 查看
以前写过一篇文章介绍怎么取得字符串的md5值。现在补充一下文件的,也是一个道理:

AnsiString fn(filename);

[code]    char p[20] = {0};  //内存
    char p1[41] = {0}; //16进制  注意41位

    CSHA1 sha1;
    sha1.HashFile(fn.c_str()); // Hash in the contents of the file
                                  // 'TheFile.cpp'
    sha1.Final();

    //sha1.ReportHash(szReport, CSHA1::REPORT_HEX); // Get final hash as
                                                  // pre-formatted string
    // or
    sha1.GetHash(p); // Get the raw message digest bytes to a
                               // temporary buffer

    BinToHex(p,p1,20);

    wsResult = WideString(p1);


注意BinToHex(p,p1,20);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: