www.pudn.com > md5cc.zip > rand_t.cpp
#include#include #include #include 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; }