这个两个东东,是我在网上找到的。小小的修改了一下方便大家使用。

一个是 获取文件哈希值的,另外一个是获取torrent文件磁力链接的哈希值。

整理好的类下载地址:

文件hash值:

http://pan.baidu.com/share/link?shareid=3718436681&uk=3037189616

torrent Hash值:

http://pan.baidu.com/share/link?shareid=3728056606&uk=3037189616

这个是QQ群 欢迎加入,一起学习编程。

// CHash.h : header file

#pragma once
#include "sha1.h" #define SIZE_OF_BUFFER 16000 class CHash
{
// Construction
public:
CString SHA1Hash(CString strHashFile);
};
// CHash.cpp : implementation file
//
#include "stdafx.h"
#include "CHash.h"
#include <atlconv.h> CString CHash::SHA1Hash(CString strHashFile)
{
USES_CONVERSION;
FILE *fileToHash = NULL;
unsigned long lenRead = 0;
unsigned char fileBuf[SIZE_OF_BUFFER];
sha1_ctx m_sha1;
unsigned char* tempOut = new unsigned char[256];
CString tempHash;
CString outHash; sha1_begin(&m_sha1); fileToHash = fopen(T2A(strHashFile), "rb");
do
{
lenRead = fread(fileBuf, 1, SIZE_OF_BUFFER, fileToHash);
if(lenRead != 0)
{
sha1_hash(fileBuf, lenRead, &m_sha1);
}
} while (lenRead == SIZE_OF_BUFFER); fclose(fileToHash); fileToHash = NULL; sha1_end(tempOut, &m_sha1); for (int i = 0 ; i < 20 ; i++)
{
char tmp[3];
_itoa(tempOut[i], tmp, 16);
if (strlen(tmp) == 1)
{
tmp[1] = tmp[0];
tmp[0] = '0';
tmp[2] = '\0';
}
tempHash += tmp; } delete[] tempOut; outHash = tempHash; return outHash;
}

最新文章

  1. SqlServer2008到期升级企业版 密钥+图解
  2. 升级到macOS 10.12 mysqlb报错ERROR 1045 (28000): Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO)
  3. Android 把电话保存到现有联系人 已有联系人
  4. Windows 8使用这半年(企业版)
  5. LINUX yum用法
  6. 2666 Accept Ratio(打表AC)
  7. [ruby on rails] 跟我学之(7)创建数据
  8. C++ 构造函数放置默认转换explicit关键字(2)
  9. 【转】Windows环境下Android Studio v1.0安装教程
  10. Android Studio实现Service AIDL
  11. ZOJ2402 Lenny's Lucky Lotto List 简单DP
  12. zabbix杂文二
  13. swift 之 函数
  14. PS 图像调整算法——阈值
  15. 【Java基本功】一文了解Java中继承、封装、多态的细节
  16. 申请IPV6地址配置IPV6域名
  17. WPF 中关于 DataTemplateSelector 类的应用
  18. 15-RUN vs CMD vs ENTRYPOINT
  19. IIS与ASP.NET中的线程池
  20. java分页算法

热门文章

  1. MySQL、SqlServer、Oracle,这三种数据库的优缺点,你知道吗?
  2. django框架1
  3. ExtJS 布局-Table布局(Table layout)
  4. Elasticsearch学习系列一(部署和配置IK分词器)
  5. NHibernte 4.0.3版本中,使用Queryover().Where().OrderBy().Skip().Take()方法分页获取数据失败
  6. dubbox、zookeeper BUG记录
  7. RPA应用场景-报税机器人
  8. UiPath键盘操作的介绍和使用
  9. SpringBoot 整合文件上传 elment Ui 上传组件
  10. 简单实现python接口自动化(一)