CMUtil/inc/hgl/util/hash/SHA1LE.h

53 lines
1.8 KiB
C
Raw Normal View History

2021-06-08 20:11:25 +08:00
#ifndef HGL_ALGORITHM_HASH_SHA1LE_INCLUDE
#define HGL_ALGORITHM_HASH_SHA1LE_INCLUDE
#include<hgl/util/hash/Hash.h>
namespace hgl
{
namespace util
{
/**
* SHA1-LE Hash算法<br>
* SHA1不变:<br>
* 1.BigEndian设计造成的LittleEndian处理器需要做大小头转换的部分
* 2.
* 3.
*/
class SHA1LE:public Hash
{
enum
{
BLOCK_SIZE = 64,
DIGEST_SIZE = 20
};
uint32 digest[5]; // Message digest
uint32 countLo; // 64-bit bit count
uint32 countHi;
uint32 data[16]; // SHA data buffer
uint32 slop; // # of bytes saved in data[]
uint32 K[4];
uint32 W[80];
private:
void sha1_transform();
public:
2024-11-26 00:39:53 +08:00
SHA1LE():Hash(20,"SHA1LE"){}
2021-06-08 20:11:25 +08:00
void Init(const uint32 *start_digest,const uint32 *mysterious_constants); ///<开始一次新的HASH计算并指定初始因子和扰乱因子
void Init()override; ///<开始一次新的HASH计算并使用缺省初始因子和扰乱因子
void SetMark(const uint32 *mysterious_constants); ///<更新扰乱因子
void Update(const void *input,uint count)override; ///<添加新的HASH数据
void Final(void *result)override; ///<结束本次HASH计算
};//class SHA1LE
}//namespace util
}//namespace hgl
#endif//HGL_ALGORITHM_HASH_SHA1LE_INCLUDE