亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sha1.cpp

?? SHA-1算法的C語言實現
?? CPP
字號:
/*
 *	sha1.cpp
 *
 *	Copyright (C) 1998
 *	Paul E. Jones <paulej@arid.us>
 *	All Rights Reserved.
 *
 *****************************************************************************
 *	$Id: sha1.cpp,v 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
 *
 *	Description:
 *		This is the constructor for the sha1 class.
 *
 *	Parameters:
 *		None.
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *
 */
SHA1::SHA1()
{
	Reset();
}

/*	
 *	~SHA1
 *
 *	Description:
 *		This is the destructor for the sha1 class
 *
 *	Parameters:
 *		None.
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *
 */
SHA1::~SHA1()
{
	// The destructor does nothing
}

/*	
 *	Reset
 *
 *	Description:
 *		This function will initialize the sha1 class member variables
 *		in preparation for computing a new message digest.
 *
 *	Parameters:
 *		None.
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *
 */
void SHA1::Reset()
{
	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;

	Computed	= false;
	Corrupted	= false;
}

/*	
 *	Result
 *
 *	Description:
 *		This function will return the 160-bit message digest into the
 *		array provided.
 *
 *	Parameters:
 *		message_digest_array: [out]
 *			This is an array of five unsigned integers which will be filled
 *			with the message digest that has been computed.
 *
 *	Returns:
 *		True if successful, false if it failed.
 *
 *	Comments:
 *
 */
bool SHA1::Result(unsigned *message_digest_array)
{
	int i;									// Counter

	if (Corrupted)
	{
		return false;
	}

	if (!Computed)
	{
		PadMessage();
		Computed = true;
	}

	for(i = 0; i < 5; i++)
	{
		message_digest_array[i] = H[i];
	}

	return true;
}

/*	
 *	Input
 *
 *	Description:
 *		This function accepts an array of octets as the next portion of
 *		the message.
 *
 *	Parameters:
 *		message_array: [in]
 *			An array of characters representing the next portion of the
 *			message.
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *
 */
void SHA1::Input(	const unsigned char	*message_array,
					unsigned 			length)
{
	if (!length)
	{
		return;
	}

	if (Computed || Corrupted)
	{
		Corrupted = true;
		return;
	}

	while(length-- && !Corrupted)
	{
		Message_Block[Message_Block_Index++] = (*message_array & 0xFF);

		Length_Low += 8;
		Length_Low &= 0xFFFFFFFF;				// Force it to 32 bits
		if (Length_Low == 0)
		{
			Length_High++;
			Length_High &= 0xFFFFFFFF;			// Force it to 32 bits
			if (Length_High == 0)
			{
				Corrupted = true;				// Message is too long
			}
		}

		if (Message_Block_Index == 64)
		{
			ProcessMessageBlock();
		}

		message_array++;
	}
}

/*	
 *	Input
 *
 *	Description:
 *		This function accepts an array of octets as the next portion of
 *		the message.
 *
 *	Parameters:
 *		message_array: [in]
 *			An array of characters representing the next portion of the
 *			message.
 *		length: [in]
 *			The length of the message_array
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *
 */
void SHA1::Input(	const char	*message_array,
					unsigned 	length)
{
	Input((unsigned char *) message_array, length);
}

/*	
 *	Input
 *
 *	Description:
 *		This function accepts a single octets as the next message element.
 *
 *	Parameters:
 *		message_element: [in]
 *			The next octet in the message.
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *
 */
void SHA1::Input(unsigned char message_element)
{
	Input(&message_element, 1);
}

/*	
 *	Input
 *
 *	Description:
 *		This function accepts a single octet as the next message element.
 *
 *	Parameters:
 *		message_element: [in]
 *			The next octet in the message.
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *
 */
void SHA1::Input(char message_element)
{
	Input((unsigned char *) &message_element, 1);
}

/*	
 *	operator<<
 *
 *	Description:
 *		This operator makes it convenient to provide character strings to
 *		the SHA1 object for processing.
 *
 *	Parameters:
 *		message_array: [in]
 *			The character array to take as input.
 *
 *	Returns:
 *		A reference to the SHA1 object.
 *
 *	Comments:
 *		Each character is assumed to hold 8 bits of information.
 *
 */
SHA1& SHA1::operator<<(const char *message_array)
{
	const char *p = message_array;

	while(*p)
	{
		Input(*p);
		p++;
	}

	return *this;
}

/*	
 *	operator<<
 *
 *	Description:
 *		This operator makes it convenient to provide character strings to
 *		the SHA1 object for processing.
 *
 *	Parameters:
 *		message_array: [in]
 *			The character array to take as input.
 *
 *	Returns:
 *		A reference to the SHA1 object.
 *
 *	Comments:
 *		Each character is assumed to hold 8 bits of information.
 *
 */
SHA1& SHA1::operator<<(const unsigned char *message_array)
{
	const unsigned char *p = message_array;

	while(*p)
	{
		Input(*p);
		p++;
	}

	return *this;
}

/*	
 *	operator<<
 *
 *	Description:
 *		This function provides the next octet in the message.
 *
 *	Parameters:
 *		message_element: [in]
 *			The next octet in the message
 *
 *	Returns:
 *		A reference to the SHA1 object.
 *
 *	Comments:
 *		The character is assumed to hold 8 bits of information.
 *
 */
SHA1& SHA1::operator<<(const char message_element)
{
	Input((unsigned char *) &message_element, 1);

	return *this;
}

/*	
 *	operator<<
 *
 *	Description:
 *		This function provides the next octet in the message.
 *
 *	Parameters:
 *		message_element: [in]
 *			The next octet in the message
 *
 *	Returns:
 *		A reference to the SHA1 object.
 *
 *	Comments:
 *		The character is assumed to hold 8 bits of information.
 *
 */
SHA1& SHA1::operator<<(const unsigned char message_element)
{
	Input(&message_element, 1);

	return *this;
}

/*	
 *	ProcessMessageBlock
 *
 *	Description:
 *		This function will process the next 512 bits of the message
 *		stored in the Message_Block array.
 *
 *	Parameters:
 *		None.
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *		Many of the variable names in this function, especially the single
 *	 	character names, were used because those were the names used
 *	  	in the publication.
 *
 */
void SHA1::ProcessMessageBlock()
{
	const unsigned K[] = 	{ 				// Constants defined for SHA-1
								0x5A827999,
								0x6ED9EBA1,
								0x8F1BBCDC,
								0xCA62C1D6
							};
	int 		t;							// Loop counter
	unsigned 	temp;						// Temporary word value
	unsigned	W[80];						// Word sequence
	unsigned	A, B, C, D, E;				// Word buffers

	/*
	 *	Initialize the first 16 words in the array W
	 */
	for(t = 0; t < 16; t++)
	{
		W[t] = ((unsigned) Message_Block[t * 4]) << 24;
		W[t] |= ((unsigned) Message_Block[t * 4 + 1]) << 16;
		W[t] |= ((unsigned) Message_Block[t * 4 + 2]) << 8;
		W[t] |= ((unsigned) Message_Block[t * 4 + 3]);
	}

	for(t = 16; t < 80; t++)
	{
	   W[t] = CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
	}

	A = H[0];
	B = H[1];
	C = H[2];
	D = H[3];
	E = H[4];

	for(t = 0; t < 20; t++)
	{
		temp = CircularShift(5,A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0];
		temp &= 0xFFFFFFFF;
		E = D;
		D = C;
		C = CircularShift(30,B);
		B = A;
		A = temp;
	}

	for(t = 20; t < 40; t++)
	{
		temp = CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
		temp &= 0xFFFFFFFF;
		E = D;
		D = C;
		C = CircularShift(30,B);
		B = A;
		A = temp;
	}

	for(t = 40; t < 60; t++)
	{
		temp = CircularShift(5,A) +
		 	   ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
		temp &= 0xFFFFFFFF;
		E = D;
		D = C;
		C = CircularShift(30,B);
		B = A;
		A = temp;
	}

	for(t = 60; t < 80; t++)
	{
		temp = CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
		temp &= 0xFFFFFFFF;
		E = D;
		D = C;
		C = CircularShift(30,B);
		B = A;
		A = temp;
	}

	H[0] = (H[0] + A) & 0xFFFFFFFF;
	H[1] = (H[1] + B) & 0xFFFFFFFF;
	H[2] = (H[2] + C) & 0xFFFFFFFF;
	H[3] = (H[3] + D) & 0xFFFFFFFF;
	H[4] = (H[4] + E) & 0xFFFFFFFF;

	Message_Block_Index = 0;
}

/*	
 *	PadMessage
 *
 *	Description:
 *		According to the standard, the message must be padded to an even
 *		512 bits.  The first padding bit must be a '1'.  The last 64 bits
 *		represent the length of the original message.  All bits in between
 *		should be 0.  This function will pad the message according to those
 *		rules by filling the message_block array accordingly.  It will also
 *		call ProcessMessageBlock() appropriately.  When it returns, it
 *		can be assumed that the message digest has been computed.
 *
 *	Parameters:
 *		None.
 *
 *	Returns:
 *		Nothing.
 *
 *	Comments:
 *
 */
void SHA1::PadMessage()
{
	/*
	 *	Check to see if the current message block is too small to hold
	 *	the initial padding bits and length.  If so, we will pad the
	 *	block, process it, and then continue padding into a second block.
	 */
	if (Message_Block_Index > 55)
	{
		Message_Block[Message_Block_Index++] = 0x80;
		while(Message_Block_Index < 64)
		{
			Message_Block[Message_Block_Index++] = 0;
		}

		ProcessMessageBlock();

		while(Message_Block_Index < 56)
		{
			Message_Block[Message_Block_Index++] = 0;
		}
	}
	else
	{
		Message_Block[Message_Block_Index++] = 0x80;
		while(Message_Block_Index < 56)
		{
			Message_Block[Message_Block_Index++] = 0;
		}

	}

	/*
	 *	Store the message length as the last 8 octets
	 */
	Message_Block[56] = (Length_High >> 24) & 0xFF;
	Message_Block[57] = (Length_High >> 16) & 0xFF;
	Message_Block[58] = (Length_High >> 8) & 0xFF;
	Message_Block[59] = (Length_High) & 0xFF;
	Message_Block[60] = (Length_Low >> 24) & 0xFF;
	Message_Block[61] = (Length_Low >> 16) & 0xFF;
	Message_Block[62] = (Length_Low >> 8) & 0xFF;
	Message_Block[63] = (Length_Low) & 0xFF;

	ProcessMessageBlock();
}


/*	
 *	CircularShift
 *
 *	Description:
 *		This member function will perform a circular shifting operation.
 *
 *	Parameters:
 *		bits: [in]
 *			The number of bits to shift (1-31)
 *		word: [in]
 *			The value to shift (assumes a 32-bit integer)
 *
 *	Returns:
 *		The shifted value.
 *
 *	Comments:
 *
 */
unsigned SHA1::CircularShift(int bits, unsigned word)
{
	return ((word << bits) & 0xFFFFFFFF) | ((word & 0xFFFFFFFF) >> (32-bits));
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
青青草国产精品97视觉盛宴| 久久久99免费| 欧美写真视频网站| 精品国产乱码久久久久久1区2区| 中文字幕在线播放不卡一区| 精品一区二区三区蜜桃| 欧美日本精品一区二区三区| 亚洲欧洲一区二区在线播放| 91丨九色丨国产丨porny| 精品国偷自产国产一区| 国产伦精一区二区三区| 日韩精品自拍偷拍| 婷婷国产在线综合| 欧美午夜免费电影| 日韩电影免费在线观看网站| 欧美日韩高清一区| 久久99蜜桃精品| 日韩亚洲欧美成人一区| 天天亚洲美女在线视频| 日韩免费观看高清完整版| 国产精品888| 欧美激情在线观看视频免费| 韩国av一区二区三区在线观看| 69久久99精品久久久久婷婷| 天使萌一区二区三区免费观看| 欧美天堂一区二区三区| 黑人精品欧美一区二区蜜桃| 亚洲精品成a人| 欧美性猛交一区二区三区精品 | 91国模大尺度私拍在线视频| 久久久久国产一区二区三区四区| 99精品欧美一区二区三区小说| 国产精品久久久久一区| aaa欧美大片| 久久精品无码一区二区三区| 色老汉一区二区三区| 精品一区二区三区日韩| 一区二区三区欧美日| 精品视频一区二区不卡| 日本网站在线观看一区二区三区| 国产精品热久久久久夜色精品三区 | 亚洲嫩草精品久久| 欧美在线999| 日韩不卡免费视频| 中文字幕一区二区三区乱码在线| 欧美日韩精品免费| fc2成人免费人成在线观看播放| 日本欧美肥老太交大片| 亚洲乱码国产乱码精品精98午夜| 日韩女优制服丝袜电影| 欧美性一级生活| 国v精品久久久网| 亚洲三级电影网站| 欧美日韩大陆在线| 91丨九色丨蝌蚪丨老版| 美女视频一区二区三区| 成人av网在线| 亚洲精品高清视频在线观看| 久久看人人爽人人| 欧美日韩久久一区| 色综合天天做天天爱| 亚洲国产视频a| 欧美xfplay| 色综合色综合色综合色综合色综合| 亚洲国产视频直播| 亚洲你懂的在线视频| 国产欧美日本一区二区三区| 2022国产精品视频| 丁香亚洲综合激情啪啪综合| 捆绑变态av一区二区三区| 亚洲午夜久久久久久久久电影院| 亚洲欧美在线观看| 国产精品久久久久久久久免费桃花 | 一本久久a久久精品亚洲| 高清在线成人网| 国产高清不卡一区| 亚洲亚洲精品在线观看| 一区二区不卡在线视频 午夜欧美不卡在| 久久品道一品道久久精品| 日韩视频不卡中文| 日韩欧美国产三级| 欧美一个色资源| 日韩女优电影在线观看| 日韩欧美在线影院| 欧美va亚洲va| 久久久久久久综合| 中文字幕+乱码+中文字幕一区| 国产日韩欧美制服另类| 国产精品久久久久桃色tv| 一区在线观看免费| 亚洲欧美一区二区三区久本道91 | 日本精品裸体写真集在线观看| 91片在线免费观看| 欧美天天综合网| 日韩无一区二区| 久久精品一区八戒影视| 中文字幕中文字幕一区| 一区二区三区成人| 视频一区视频二区在线观看| 免费看欧美女人艹b| 国产露脸91国语对白| av不卡在线观看| 一本色道久久综合亚洲aⅴ蜜桃 | 粉嫩欧美一区二区三区高清影视| 国产精品66部| 99久免费精品视频在线观看| 91久久人澡人人添人人爽欧美| 欧美精品乱人伦久久久久久| 99re视频这里只有精品| 欧美调教femdomvk| 精品国产乱码久久久久久蜜臀 | 欧美精品一二三区| 精品国产乱码久久久久久蜜臀| 国产精品乱人伦| 午夜影视日本亚洲欧洲精品| 亚洲午夜在线视频| 久久国产精品99精品国产| 成人午夜激情视频| 国产成人精品免费视频网站| 91污在线观看| 日韩精品一区国产麻豆| 国产精品萝li| 婷婷综合在线观看| 丰满亚洲少妇av| 欧美乱妇一区二区三区不卡视频| 久久精品免视看| 亚洲国产精品精华液网站| 国产一区二区三区观看| 欧美亚洲一区二区在线| 久久久久久麻豆| 丝袜脚交一区二区| 91欧美激情一区二区三区成人| 欧美大胆人体bbbb| 亚洲精品视频免费观看| 国产精品夜夜爽| 欧美一区三区二区| 精品国产髙清在线看国产毛片| 亚洲三级免费观看| 国产一区二区中文字幕| 在线视频一区二区三| 久久久国产精品不卡| 五月天激情综合网| 色中色一区二区| 国产欧美一区二区三区鸳鸯浴 | 青青青伊人色综合久久| 色综合色狠狠天天综合色| 国产亚洲精品aa| 蜜桃精品视频在线| 欧美精品黑人性xxxx| 一区二区在线观看视频| 成人午夜私人影院| 国产午夜精品久久久久久久| 久久精品国内一区二区三区| 欧美日韩国产区一| 亚洲国产一二三| 欧美午夜精品久久久久久超碰| 6080yy午夜一二三区久久| 成人一区二区三区中文字幕| 6080亚洲精品一区二区| 亚洲一区二区三区国产| 三级欧美韩日大片在线看| 色网综合在线观看| 亚洲日本免费电影| 不卡的av电影在线观看| 国产精品卡一卡二卡三| 国产成人综合亚洲网站| 久久综合九色综合97婷婷| 久久精品噜噜噜成人av农村| 欧美一区二区免费| 视频一区欧美精品| 884aa四虎影成人精品一区| 亚洲综合在线视频| 欧洲精品在线观看| 亚洲图片一区二区| 欧美私人免费视频| 亚洲sss视频在线视频| 欧美日韩视频不卡| 偷拍与自拍一区| 日韩午夜电影av| 狠狠色丁香久久婷婷综合_中| 久久夜色精品国产噜噜av| 久久草av在线| 欧美极品美女视频| 91性感美女视频| 午夜成人在线视频| 欧美精品一区在线观看| 国产精品1024| 亚洲欧洲精品一区二区三区| 91视频在线看| 亚洲国产精品人人做人人爽| 欧美一区二区在线看| 狠狠色狠狠色综合| 日本久久一区二区| 成人黄色网址在线观看| 国产精品日产欧美久久久久| 91在线免费播放| 五月婷婷综合网| 精品国产一区二区三区久久影院| 国产成人自拍网| 亚洲综合激情小说|