91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-10
  • 語言: C/C++
  • 標簽: SHA1??C++??

資源簡介

標準SHA1算法的C++實現,講解了該算法的計算原理,并對難懂代碼進行解釋和具體的使用方法。拿來就能用。

資源截圖

代碼片段和文件信息

/*
?* sha1.cpp
?*
?* Copyright?(C)?1998
?* Paul?E.?Jones?
?* All?Rights?Reserved.
?*
?*****************************************************************************
?* $Id:?sha1.cppv?1.9?2004/03/27?18:02:20?paulej?Exp?$
?*****************************************************************************
?*
?* Description:
?*? This?class?implements?the?Secure?Hashing?Standard?as?defined
?*? in?FIPS?PUB?180-1?published?April?17?1995.
?*
?*? The?Secure?Hashing?Standard?which?uses?the?Secure?Hashing
?*? Algorithm?(SHA)?produces?a?160-bit?message?digest?for?a
?*? given?data?stream.??In?theory?it?is?highly?improbable?that
?*? two?messages?will?produce?the?same?message?digest.??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?was
?*? written?with?the?expectation?that?the?processor?has?at?least
?*? a?32-bit?machine?word?size.??If?the?machine?word?size?is?larger
?*? the?code?should?still?function?properly.??One?caveat?to?that
?* is?that?the?input?functions?taking?characters?and?character?arrays
?* assume?that?only?8?bits?of?information?are?stored?in?each?character.
?*
?* 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?8
?*? bits.
?*
?*/


#include?“sha1.h“

SHA1::SHA1()
{
SHAInit();
}

SHA1::~SHA1()
{
}

void?SHA1::SHAInit()
{
Length_Low =?0;
Length_High =?0;
Message_Block_Index =?0;

H[0] =?0x67452301;
H[1] =?0xEFCDAB89;
H[2] =?0x98BADCFE;
H[3] =?0x10325476;
H[4] =?0xC3D2E1F0;
}

//?space?of?lpSHACode_Output?must?be?>=?20?bytes;
bool?SHA1::SHA_GO(?const?char?*lpData_Input?char?*lpSHACode_Output?)
{
if?(lpData_Input?==?NULL?||?lpSHACode_Output?==?NULL)
return?false;

SHAInit();

//?One?times?analyse?64Bytes?512?bits.
int?nInputLen?=?strlen(lpData_Input);
int?nDealDataLen?=?0; // the?length?of?can-deal-data?this?times;
for(int?pos=0?;?pos<=nInputLen?;?pos+=64)
{
if?(nInputLen?-?pos?>=?64)
{
nDealDataLen?=?64; //?input-data?is?enough?fill?64bytes
memset(Message_Block?0?sizeof(Message_Block));
memcpy(Message_Block?lpData_Input?+?pos?nDealDataLen);

AddDataLen(nDealDataLen);
ProcessMessageBlock();
AddDataLen(0);
}
else
{
nDealDataLen?=?nInputLen?-?pos; // input-data?isn‘t?enough?fill?64bytesneed?fill?0x8000000000?and?lenth?of?real-data.
memset(Message_Block?0?sizeof(Message_Block));
memcpy(Message_Block?lpData_Input?+?pos?nDealDataLen);

AddDataLen(nDealDataLen);
PadMessage();
}
}

//?copy?result?to?output
for?(int?i?=?0;?i? {
sprintf(&(lpSHACode_Output[8*

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2648??2009-04-20?18:08??sha1.h

?????文件???????7797??2009-04-20?17:58??sha1.cpp

-----------?---------??----------?-----??----

????????????????10445????????????????????2


評論

共有 條評論