资源简介
SHA1校验和算法实现,带vs工程源码

代码片段和文件信息
/* sha1sum.c - print SHA-1 Message-Digest Algorithm
* Copyright (C) 1998 1999 2000 2001 Free Software Foundation Inc.
* Copyright (C) 2004 g10 Code GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software Foundation
* Inc. 59 Temple Place - Suite 330 Boston MA 02111-1307 USA.
*/
/* SHA-1 coden take from gnupg 1.3.92.
Note that this is a simple tool to be used for MS Windows.
*/
#include
#include
#include
#include
#include
#undef BIG_ENDIAN_HOST
typedef unsigned int u32;
/****************
* Rotate a 32 bit integer by n bytes
****************/
#if defined(__GNUC__) && defined(__i386__)
static inline u32 rol( u32 x int n)
{
__asm__(“roll %%cl%0“
:“=r“ (x)
:“0“ (x)“c“ (n));
return x;
}
#else
#define rol(xn) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif
typedef struct {
u32 h0h1h2h3h4; //哈希计算后的结果是20个bit,刚好相当于5个unsigned int(4字节)类型的数据
u32 nblocks;
unsigned char buf[64];
int count;
} SHA1_CONTEXT;
void sha1_init( SHA1_CONTEXT *hd ) //计算前进行初始化
{
hd->h0 = 0x67452301;
hd->h1 = 0xefcdab89;
hd->h2 = 0x98badcfe;
hd->h3 = 0x10325476;
hd->h4 = 0xc3d2e1f0;
hd->nblocks = 0;
hd->count = 0;
}
/*
* Transform the message X which consists of 16 32-bit-words
*/
static void
transform( SHA1_CONTEXT *hd unsigned char *data )
{
u32 abcdetm;
u32 x[16];
/* get values from the chaining vars */
a = hd->h0;
b = hd->h1;
c = hd->h2;
d = hd->h3;
e = hd->h4;
#ifdef BIG_ENDIAN_HOST
memcpy( x data 64 );
#else
{ int i;
unsigned char *p2;
for(i=0 p2=(unsigned char*)x; i < 16; i++ p2 += 4 ) {
p2[3] = *data++;
p2[2] = *data++;
p2[1] = *data++;
p2[0] = *data++;
}
}
#endif
#define K1 0x5A827999L
#define K2 0x6ED9EBA1L
#define K3 0x8F1BBCDCL
#define K4 0xCA62C1D6L
#define F1(xyz) ( z ^ ( x & ( y ^ z ) ) )
#define F2(xyz) ( x ^ y ^ z )
#define F3(xyz) ( ( x & y ) | ( z & ( x | y ) ) )
#define F4(xyz) ( x ^ y ^ z )
#define M(i) ( tm = x[i&0x0f] ^ x[(i-14)&0x0f] \
^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f] \
(x[i&0x0f] = rol(tm1)) )
#define R(abcdefkm) do { e += rol(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 39936 2016-09-14 18:39 sha1sum\sha1sum\Debug\sha1sum.exe
文件 326476 2016-09-14 18:39 sha1sum\sha1sum\Debug\sha1sum.ilk
文件 371712 2016-09-14 18:39 sha1sum\sha1sum\Debug\sha1sum.pdb
文件 2359296 2016-09-16 21:02 sha1sum\sha1sum\ipch\sha1sum-9070178e\sha1sum-e04e56ae.ipch
文件 672 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\cl.command.1.tlog
文件 2140 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\CL.read.1.tlog
文件 354 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\CL.write.1.tlog
文件 1320 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\li
文件 2428 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\li
文件 624 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\li
文件 22068 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\main.obj
文件 460 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\mt.command.1.tlog
文件 644 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\mt.read.1.tlog
文件 284 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\mt.write.1.tlog
文件 381 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\sha1sum.exe.intermediate.manifest
文件 63 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\sha1sum.lastbuildstate
文件 3155 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\sha1sum.log
文件 52224 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\vc100.idb
文件 69632 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug\vc100.pdb
文件 10667 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\main.cpp
文件 3221 2016-09-14 18:35 sha1sum\sha1sum\sha1sum\sha1sum.vcxproj
文件 953 2016-09-14 18:35 sha1sum\sha1sum\sha1sum\sha1sum.vcxproj.filters
文件 143 2016-09-14 18:34 sha1sum\sha1sum\sha1sum\sha1sum.vcxproj.user
文件 2248704 2016-09-16 21:05 sha1sum\sha1sum\sha1sum.sdf
文件 888 2016-09-14 18:34 sha1sum\sha1sum\sha1sum.sln
..A..H. 18432 2016-09-16 21:05 sha1sum\sha1sum\sha1sum.suo
目录 0 2016-09-16 21:02 sha1sum\sha1sum\ipch\sha1sum-9070178e
目录 0 2016-09-14 18:39 sha1sum\sha1sum\sha1sum\Debug
目录 0 2016-09-14 18:39 sha1sum\sha1sum\Debug
目录 0 2016-09-16 21:02 sha1sum\sha1sum\ipch
............此处省略6个文件信息
相关资源
- AE开发Windows最短路径分析
-
Windows em
bedded Compact 2013 应用开发调 - 黑苹果硬件兼容检测和查询软件
- Uninstall_Cortana_WINCLIENT.CN.rar
- VMware65_SLP_DeLLSLIC2.1
- Windows异步套接字网络编程
- WINDOWS98启动盘镜像Win98.IMA
- 仿windows记事本
- ado数据库MFC图书管理系统vs2010
- windows7用的,非常漂亮的透明计时器
- windows下制作macOS安装U盘,绝对简单好
- keil vcom windows 7 64bit 驱动
- windows ce 系统的GPIO驱动程序
- TCP 发包工具(windows)
- 微软的可以删除系统卸不干净的软件
- windows下生成MD5值的工具(WinMD5)
- windows cygwin ns2安装步骤
- WinAPI 函数库(大全)
- 解决在Windows XP SP2下不能显示验证码的
- 加快Windows XP操作系统开机速度
-
解决安装vs2012后vs2010 li
nk : fatal er - Windows 1.0 软盘镜像
- Windows下访问LINUX的利器-SSH
- ChilledWindows.exe(玩笑病毒)
- NDK-R12B windows-x86_64百度云盘
- windows3.2简体中文版,虚拟机文件
- Windows 3.0 安装软盘(3.5 720k)
- WINDOWS内核安全编程 寒江独钓 光盘源
- 寒江独钓-Windows内核安全编程(完整版
- 实现Windows与Linux两系统间自由切换
评论
共有 条评论