⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ripemd.h

📁 计算机安全的 多种密码算法演示
💻 H
字号:
// RIPEM.h: interface for the CRIPEM class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_RIPEMD_H__56BDAD81_1478_11D5_80AC_0000E8810675__INCLUDED_)
#define AFX_RIPEMD_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 RIPEMD
#ifndef PROTOTYPES
#define PROTOTYPES 0
#endif
 /* Length of test block, number of test blocks. */
#define TEST_BLOCK_LEN 1000
#define TEST_BLOCK_COUNT 1000


 /* Constants for RIPTransform routine. */
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 */
}RIP_CTX;


#define k0 0
#define k1 0x5a827999
#define k2 0x6ed9eba1
#define k3 0x8f1bbcdc
#define k4 0xa953fd4e
#define k5 0x50a28be6
#define k6 0x5c4dd124
#define k7 0x6d703ef3
#define k8 0x7a6d76e9
#define k9 0

#define F(x, y, z) ((x) ^ (y) ^ (z))
#define G(x, y, z) (z ^ (x & (y^z)))
#define H(x, y, z) (z ^ (x | ~y))
#define I(x, y, z) (y ^ (z & (x^y)))
#define J(x, y, z) (x ^ (y | ~z))

/* 
   ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))

/*
   FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
   Rotation is separate from addition to prevent recomputation.
*/
 #define Subround(f, a, b, c, d, e, x, s, k)        \
{	a += f(b, c, d) + x + k;\
	a = ROTATE_LEFT((UINT4)a, (unsigned int)s) + e;\
	c = ROTATE_LEFT((UINT4)c, 10U); \
}
class CRIPEMD  
{
public:
	CRIPEMD();
	virtual ~CRIPEMD();

public:
	char* RIPString (char*);
	//char* RIPFile (CString filename);
	CString RIPFile(CString filename);
	char* hmac_rip(char* text, char* key);
	//char* RIPtring PROTO_LIST ((char *));
	//char* RIPFile PROTO_LIST ((char *));

private:
	void RIPInit (RIP_CTX *context);
	void RIPUpdate(RIP_CTX *context, unsigned char *input,unsigned int inputLen);
	void RIPFinal (unsigned char digest[16], RIP_CTX *context);
	void RIPTransform  (UINT4 [4], unsigned char [64]) ;
	void Encode(unsigned char *, UINT4 *, unsigned int);
	void Decode (UINT4 *, unsigned char *, unsigned int);
	void RIP_memcpy(POINTER, POINTER, unsigned int);
	void RIP_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 + -