CMUtil/inc/hgl/util/hash/SHA1LE.h
2024-11-26 00:39:53 +08:00

53 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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:
SHA1LE():Hash(20,"SHA1LE"){}
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