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

📄 rand_t.cpp

📁 属于加密解密领域的
💻 CPP
字号:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>

extern "C" 
{ 
	#include "global.h"
}

// MD5("634634") = 2eb621f1638c200faa63371dc4718ab6

union
{
	unsigned int IVi[4];
	unsigned char IVc[16];	
} g_IV = { 0x2eb621f1, 0x638c200f, 0xaa63371d, 0xc4718ab6 }; 

#define RL(x, y) (((x) << (y)) | ((x) >> (32 - (y))))
#define RR(x, y) (((x) >> (y)) | ((x) << (32 - (y))))


unsigned int random()
{
	unsigned int x = RL((unsigned int)rand(), 16);
	unsigned int y = (unsigned int)rand();
	printf("x = %08x\ty = %04x\t", x, y);
	return x + y;
	// return (unsigned int)(RL((unsigned int)rand(), 16) + (unsigned int)rand());
}

int main()
{
	printf("hello, rand_t!\n");

	int i = add(1,5);

	// self build test
	if(4 == sizeof(unsigned int))
	{
		printf("unsigned int is %d-bit, self test ok\n", sizeof(unsigned int) * 8);
	}
	else
	{
		printf("unsigned int is %d-bit, self test failed. please built as 32-bit.\n", sizeof(unsigned int) * 8);
	}
	
	srand((unsigned)time(NULL));

	int a;

	printf("sizeof(a) = %d\n", sizeof(a));

	for(int i=1; i<20; i++)
	{
		a = random();
		printf("a = 0x%08x\n", a);
	}

	getch();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -