📄 sha1.h
字号:
// SHA1.h: interface for the CRIPEM class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SHA1A_H__56BDAD81_1478_11D5_80AC_0000E8810675__INCLUDED_)
#define AFX_SHA1A_H__56BDAD81_1478_11D5_80AC_0000E8810675__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <stdio.h>
#include <time.h>
#include <string.h>
#define SHA1
#ifndef PROTOTYPES
#define PROTOTYPES 0
#endif
/* Length of test block, number of test blocks. */
#define TEST_BLOCK_LEN 1000
#define TEST_BLOCK_COUNT 1000
typedef unsigned char *POINTER; /* POINTER defines a generic pointer type */
typedef unsigned short int UINT2; /* UINT2 defines a two byte word */
typedef unsigned long int UINT4; /* UINT4 defines a four byte word */
typedef struct
{
UINT4 state[5]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
}SHA_CTX;
#define K1 0x5a827999
#define K2 0x6ed9eba1
#define K3 0x8f1bbcdc
#define K4 0xca62c1d6
#define f1(x, y, z) ((x & y)|(~x & z))
#define f2(x, y, z) ((x) ^ (y) ^ (z))
#define f3(x, y, z) ((x & y)|(x & z)|(y & z))
#define f4(x, y, z) ((x) ^ (y) ^ (z))
/*
ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
#define expand(W,i) ( W[ i & 15 ] = ROTATE_LEFT( (W[i&15] ^ W[i-14&15] ^ \
W[i-8&15] ^ W[i-3&15]), 1U) )
/*
FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
#define subRound(a, b, c, d, e, f, k, data) \
( e += ROTATE_LEFT(a,5U) + f(b,c,d) + k + data, b = ROTATE_LEFT(b,30U))
class CSHA
{
public:
CSHA();
virtual ~CSHA();
public:
char* SHAString (char*);
//char* SHAFile (CString filename);
CString SHAFile(CString filename);
char* hmac_sha(char* text, char* key);
//char* SHAtring PROTO_LIST ((char *));
//char* SHAFile PROTO_LIST ((char *));
private:
void SHAInit (SHA_CTX *context);
void SHAUpdate(SHA_CTX *context, unsigned char *input,unsigned int inputLen);
void SHAFinal (unsigned char digest[16], SHA_CTX *context);
void SHATransform (UINT4 [4], unsigned char [64]) ;
void Encode(unsigned char *, UINT4 *, unsigned int);
void Decode (UINT4 *, unsigned char *, unsigned int);
void SHA_memcpy(POINTER, POINTER, unsigned int);
void SHA_memset(POINTER, int, unsigned int);
//LONG RIP_Os2ip(char* pstr);
};
#endif // !defined(AFX_RIPA_H__56BDAD81_1478_11D5_80AC_0000E8810675__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -