md5test.cpp
上传用户:jhonsonho
上传日期:2021-11-15
资源大小:15k
文件大小:1k
源码类别:

CA认证

开发平台:

Visual C++

  1. // md5test.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include "md5.h"
  5. int _tmain(int argc, _TCHAR* argv[])
  6. {
  7. static const char *const test[7] = { "", /*d41d8cd98f00b204e9800998ecf8427e*/ "945399884.61923487334tuvga", /*0cc175b9c0f1b6a831c399e269772661*/ "abc", /*900150983cd24fb0d6963f7d28e17f72*/ "message digest", /*f96b697d7cb7938d525a2f31aaf161d0*/ "abcdefghijklmnopqrstuvwxyz", /*c3fcd3d76192e4007dfb496cca67e13b*/ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", /*d174ab98d277d9f5a5611c2c9f419d9f*/ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" /*57edf4a22be3c955ac49da2e2107b67a*/     };     int i;     for (i = 0; i < 7; ++i) { md5_state_t state; md5_byte_t digest[16]; int di; char buf[1024]; md5_init(&state); md5_append(&state, (const md5_byte_t *)test[i], strlen(test[i])); md5_finish(&state, digest); // MD5( (char*)test[i], strlen(test[i]), buf); printf("MD5 ("%s") = ", test[i]); for (di = 0; di < 16; ++di) printf("%02x", digest[di]); digest[15] = 0; di = atoi((char*)&digest[0]); printf("n");     }
  8. return 0;
  9. }