資源簡介
將SHA1封裝在一個DLL中,方便使用,有源碼,(源碼用了 作者 - 張魯奪(zhangluduo)
MSN - zhangluduo@msn.com
QQ群 - 34064264
為所有愛我的人和我愛的人努力!)
我只是封裝了下,便于使用以后
調(diào)用函數(shù)CString GiveSha1(CString filename),filename文件名用\\

代碼片段和文件信息
/*
?*??SHA1.c
?*
?*??Description:
?*??????This?file?implements?the?Secure?Hashing?Algorithm?1?as
?*??????defined?in?FIPS?PUB?180-1?published?April?17?1995.
?*
?*??????The?SHA-1?produces?a?160-bit?message?digest?for?a?given
?*??????data?stream.??It?should?take?about?2**n?steps?to?find?a
?*??????message?with?the?same?digest?as?a?given?message?and
?*??????2**(n/2)?to?find?any?two?messages?with?the?same?digest
?*??????when?n?is?the?digest?size?in?bits.??Therefore?this
?*??????algorithm?can?serve?as?a?means?of?providing?a
?*??????“fingerprint“?for?a?message.
?*
?*??Portability?Issues:
?*??????SHA-1?is?defined?in?terms?of?32-bit?“words“.??This?code
?*??????uses??(included?via?“sha1.h“?to?define?32?and?8
?*??????bit?unsigned?integer?types.??If?your?C?compiler?does?not
?*??????support?32?bit?unsigned?integers?this?code?is?not
?*??????appropriate.
?*
?*??Caveats:
?*??????SHA-1?is?designed?to?work?with?messages?less?than?2^64?bits
?*??????long.??Although?SHA-1?allows?a?message?digest?to?be?generated
?*??????for?messages?of?any?number?of?bits?less?than?2^64?this
?*??????implementation?only?works?with?messages?with?a?length?that?is
?*??????a?multiple?of?the?size?of?an?8-bit?character.
?*
?*/
/*
Copyright?2006?-?2008
ZhangLuduo?
All?Rights?Reserved.
SHA1算法實現(xiàn)?此份代碼參考了RFC3174.txt?
對源碼略有修改
作者 -?張魯奪(zhangluduo)
MSN -?zhangluduo@msn.com
QQ群 -?34064264
為所有愛我的人和我愛的人努力!
*/
#include?“stdafx.h“
#include?“SHA1.h“
//?Define?the?SHA1?circular?left?shift?macro
#define?SHA1CircularShift(bits?word)?((((word)?<(bits))?&?0xFFFFFFFF)?|?((word)?>>?(32?-?(bits))))
SHA1::SHA1()
{
}
SHA1::~SHA1()
{
}
/**?SHA1Reset
Description:
This?function?will?initialize?the?SHA1Context?in?preparation
for?computing?a?new?SHA1?message?digest.
Parameters:
context:?[in/out]
The?context?to?reset.
*/
void?SHA1::SHA1Reset?(SHA1Context*?context)
{
????context->Length_Low?????????????=?0;
????context->Length_High????????????=?0;
????context->Message_Block_Index????=?0;
????context->Message_Digest[0]??????=?0x67452301;
????context->Message_Digest[1]??????=?0xEFCDAB89;
????context->Message_Digest[2]??????=?0x98BADCFE;
????context->Message_Digest[3]??????=?0x10325476;
????context->Message_Digest[4]??????=?0xC3D2E1F0;
????context->Computed???=?0;
????context->Corrupted??=?0;
}
/**?SHA1Input
Description:
This?function?accepts?an?array?of?octets?as?the?next?portion
of?the?message.
Parameters:
context:?[in/out]
The?SHA?context?to?update
message_array:?[in]
An?array?of?characters?representing?the?next?portion?of
the?message.
length:?[in]
The?length?of?the?message?in?message_array
*/
int?SHA1::SHA1Input(SHA1Context*?context?const?unsigned?char*?message_array?unsigned?length)
{
if?(!length?||?!context?||?!message_array)
return?SHA_NULL;
if?(context->Computed)
{
context->Corrupted?=?SHA_
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2800??2009-10-29?14:50??sha1\SHADLG\SHADLG\ReadMe.txt
?????文件??????21630??2003-04-01?19:36??sha1\SHADLG\SHADLG\res\SHADLG.ico
?????文件????????695??2009-10-29?14:50??sha1\SHADLG\SHADLG\res\SHADLG.manifest
?????文件????????362??2009-10-29?14:50??sha1\SHADLG\SHADLG\res\SHADLG.rc2
?????文件????????862??2009-10-30?09:19??sha1\SHADLG\SHADLG\resource.h
?????文件???????9593??2008-02-23?23:23??sha1\SHADLG\SHADLG\SHA1.cpp
?????文件??????42146??2008-02-23?23:23??sha1\SHADLG\SHADLG\SHA1.h
?????文件???????2958??2009-10-30?08:43??sha1\SHADLG\SHADLG\SHA1Ex.cpp
?????文件???????1488??2009-10-30?08:41??sha1\SHADLG\SHADLG\SHA1Ex.h
?????文件??????58392??2009-10-30?09:19??sha1\SHADLG\SHADLG\SHADLG.APS
?????文件???????1452??2009-10-29?14:50??sha1\SHADLG\SHADLG\SHADLG.cpp
?????文件????????437??2009-10-29?14:50??sha1\SHADLG\SHADLG\SHADLG.h
?????文件???????5251??2009-10-30?09:19??sha1\SHADLG\SHADLG\SHADLG.rc
?????文件???????4921??2009-10-30?08:40??sha1\SHADLG\SHADLG\SHADLG.vcproj
?????文件???????3846??2009-10-30?09:21??sha1\SHADLG\SHADLG\SHADLGDlg.cpp
?????文件????????827??2009-10-30?09:14??sha1\SHADLG\SHADLG\SHADLGDlg.h
?????文件?????143360??2009-10-30?09:21??sha1\SHADLG\SHADLG\shadll.dll
?????文件????????135??2009-10-29?14:50??sha1\SHADLG\SHADLG\stdafx.cpp
?????文件???????1458??2009-10-29?14:50??sha1\SHADLG\SHADLG\stdafx.h
?????文件??????52224??2009-10-30?09:21??sha1\SHADLG\SHADLG.ncb
?????文件????????908??2009-10-29?14:50??sha1\SHADLG\SHADLG.sln
????..A..H.?????10240??2009-10-30?09:21??sha1\SHADLG\SHADLG.suo
?????文件???????1643??2009-10-30?09:00??sha1\shadll\shadll\ReadMe.txt
?????文件????????373??2009-10-30?09:00??sha1\shadll\shadll\res\shadll.rc2
?????文件????????366??2009-10-30?09:00??sha1\shadll\shadll\Resource.h
?????文件???????9593??2008-02-23?23:23??sha1\shadll\shadll\SHA1.cpp
?????文件??????42146??2008-02-23?23:23??sha1\shadll\shadll\SHA1.h
?????文件???????2958??2009-10-30?08:43??sha1\shadll\shadll\SHA1Ex.cpp
?????文件???????1488??2009-10-30?08:41??sha1\shadll\shadll\SHA1Ex.h
?????文件???????1691??2009-10-30?09:21??sha1\shadll\shadll\shadll.cpp
............此處省略18個文件信息
- 上一篇:觸摸按鍵芯片 TTP226
- 下一篇:labview智能小車小車控制上位機
評論
共有 條評論