C++ 文件hash值 BT种子的hash值
2024-10-20 06:28:06
这个两个东东,是我在网上找到的。小小的修改了一下方便大家使用。
一个是 获取文件哈希值的,另外一个是获取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;
}
最新文章
- SqlServer2008到期升级企业版 密钥+图解
- 升级到macOS 10.12 mysqlb报错ERROR 1045 (28000): Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO)
- Android 把电话保存到现有联系人 已有联系人
- Windows 8使用这半年(企业版)
- LINUX yum用法
- 2666 Accept Ratio(打表AC)
- [ruby on rails] 跟我学之(7)创建数据
- C++ 构造函数放置默认转换explicit关键字(2)
- 【转】Windows环境下Android Studio v1.0安装教程
- Android Studio实现Service AIDL
- ZOJ2402 Lenny's Lucky Lotto List 简单DP
- zabbix杂文二
- swift 之 函数
- PS 图像调整算法——阈值
- 【Java基本功】一文了解Java中继承、封装、多态的细节
- 申请IPV6地址配置IPV6域名
- WPF 中关于 DataTemplateSelector 类的应用
- 15-RUN vs CMD vs ENTRYPOINT
- IIS与ASP.NET中的线程池
- java分页算法
热门文章
- MySQL、SqlServer、Oracle,这三种数据库的优缺点,你知道吗?
- django框架1
- ExtJS 布局-Table布局(Table layout)
- Elasticsearch学习系列一(部署和配置IK分词器)
- NHibernte 4.0.3版本中,使用Queryover().Where().OrderBy().Skip().Take()方法分页获取数据失败
- dubbox、zookeeper BUG记录
- RPA应用场景-报税机器人
- UiPath键盘操作的介绍和使用
- SpringBoot 整合文件上传 elment Ui 上传组件
- 简单实现python接口自动化(一)