- 论坛徽章:
- 0
|
- #include <stdio.h>
- #include <sys/types.h>
- #include <stdio.h>
- #include <string.h>
- #include <openssl/md5.h>
- int HexChange(const unsigned char* pcBuf, unsigned char* cStore, unsigned int iLen)
- {
- for( unsigned int i = 0; i < iLen; i++ )
- {
- sprintf( (char*)(&cStore[i*2]), "%02x", *(pcBuf + i) );
- }
- return 0;
- }
- int main(void)
- {
- unsigned char tk[36];
- const char *key="abc";
- int key_len=strlen(key);
- MD5_CTX tctx;
- MD5_Init(&tctx);
- MD5_Update(&tctx,(unsigned char*) key, key_len);
- MD5_Final(tk, &tctx);
- unsigned char cBuf[1024];
- bzero( cBuf, sizeof( cBuf ) );
- HexChange( tk, cBuf, 16 );
- printf( "%s\n", cBuf );
- return 0;
- }
复制代码
再急也要把字写对了,
- MD5Init(&tctx);
- MD5Update(&tctx,(unsigned char*) key, key_len);
- MD5Final(tk, &tctx);
复制代码
你的机器上有上述三个函数么?
[ 本帖最后由 isnowran 于 2006-6-5 16:36 编辑 ] |
|