• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MD5Final函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MD5Final函数的典型用法代码示例。如果您正苦于以下问题:C++ MD5Final函数的具体用法?C++ MD5Final怎么用?C++ MD5Final使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MD5Final函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: smbfs_getino

/*
 * Lack of inode numbers leads us to the problem of generating them.
 * Partially this problem can be solved by having a dir/file cache
 * with inode numbers generated from the incremented by one counter.
 * However this way will require too much kernel memory, gives all
 * sorts of locking and consistency problems, not to mentinon counter overflows.
 * So, I'm decided to use a hash function to generate pseudo random (and unique)
 * inode numbers.
 */
static long
smbfs_getino(struct smbnode *dnp, const char *name, int nmlen)
{
#ifdef USE_MD5_HASH
	MD5_CTX md5;
	u_int32_t state[4];
	long ino;
	int i;

	MD5Init(&md5);
	MD5Update(&md5, name, nmlen);
	MD5Final((u_char *)state, &md5);
	for (i = 0, ino = 0; i < 4; i++)
		ino += state[i];
	return dnp->n_ino + ino;
#endif
	u_int32_t ino;

	ino = dnp->n_ino + hash32_strn(name, nmlen, HASH32_STR_INIT);
	if (ino <= 2)
		ino += 3;
	return ino;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:32,代码来源:smbfs_smb.c


示例2: search

// Search all strings of length 'len' for one that hashes to 'hash'.
void *
search(void *args)
{
	search_args *a = args;
	assert(a->lo < a->hi);
	assert(a->hi <= a->len);

	//cprintf("searching strings starting from '%s'\n", a->str);
	do {
		unsigned char h[16];
		//cprintf("checking '%s'\n", a->str);
		MD5_CTX ctx;
		MD5Init(&ctx);
		MD5Update(&ctx, a->str, a->len);
		MD5Final(h, &ctx);
		if (memcmp(h, a->hash, 16) == 0) {
			strcpy(out, (char*)a->str);
			found = 1;
			return NULL;
		}
	} while (!incstr(a->str, a->lo, a->hi));
	return NULL;
}
开发者ID:Mic92,项目名称:Determinator,代码行数:24,代码来源:bcrack.c


示例3: set_md5sum

static void set_md5sum(HIO_HANDLE *f, unsigned char *digest)
{
	unsigned char buf[BUFLEN];
	MD5_CTX ctx;
	int bytes_read;
	struct stat st;

	if (hio_stat(f, &st) < 0)
		return;

	if (st.st_size <= 0) {
		memset(digest, 0, 16);
		return;
	}

	hio_seek(f, 0, SEEK_SET);

	MD5Init(&ctx);
	while ((bytes_read = hio_read(buf, 1, BUFLEN, f)) > 0) {
		MD5Update(&ctx, buf, bytes_read);
	}
	MD5Final(digest, &ctx);
}
开发者ID:visy,项目名称:turha,代码行数:23,代码来源:load.c


示例4: encode_wkssvc_join_password_buffer

void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx,
					const char *pwd,
					DATA_BLOB *session_key,
					struct wkssvc_PasswordBuffer **pwd_buf)
{
	uint8_t buffer[516];
	MD5_CTX ctx;
	struct wkssvc_PasswordBuffer *my_pwd_buf = NULL;
	DATA_BLOB confounded_session_key;
	int confounder_len = 8;
	uint8_t confounder[8];

	my_pwd_buf = talloc_zero(mem_ctx, struct wkssvc_PasswordBuffer);
	if (!my_pwd_buf) {
		return;
	}

	confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);

	encode_pw_buffer(buffer, pwd, STR_UNICODE);

	generate_random_buffer((uint8_t *)confounder, confounder_len);

	MD5Init(&ctx);
	MD5Update(&ctx, session_key->data, session_key->length);
	MD5Update(&ctx, confounder, confounder_len);
	MD5Final(confounded_session_key.data, &ctx);

	arcfour_crypt_blob(buffer, 516, &confounded_session_key);

	memcpy(&my_pwd_buf->data[0], confounder, confounder_len);
	memcpy(&my_pwd_buf->data[8], buffer, 516);

	data_blob_free(&confounded_session_key);

	*pwd_buf = my_pwd_buf;
}
开发者ID:AIdrifter,项目名称:samba,代码行数:37,代码来源:smbencrypt.c


示例5: MD5String

std::string MD5String(int stringCount, ...)
{
	MD5_CTX context;
	unsigned char digest[16];
	va_list arguments;

	// Prepare hash.
	MD5Init(&context);

	// Hash all strings.
	va_start(arguments, stringCount);
	for (int x = 0; x < stringCount; x++)
	{
		auto nextString = va_arg(arguments, std::string);
		const char* stringContent = nextString.c_str();
		unsigned int len = strlen(stringContent);
		MD5Update(&context, (unsigned char *)stringContent, len);
	}
	va_end(arguments);

	// Finalize hash.
	MD5Final(digest, &context);

	// Convert from binary to hex.
	char digestStringBuffer[64];

	unsigned int i;
	unsigned int bytes = 0;

	for (i = 0; i < 16; i++)
	{
		bytes += sprintf_s(digestStringBuffer + bytes, 64 - bytes, "%02x", digest[i]);
	}

	// Convert to string.
	return std::string(digestStringBuffer);
}
开发者ID:npruehs,项目名称:pinned-down-server,代码行数:37,代码来源:MD5String.cpp


示例6: Hashit

static void Hashit(TCHAR *filename)
{
	FILE *FileToHash;
	MD5_CTX MDContext;
	int bytes;
	int i;
	unsigned char data[1024];
	unsigned char hash[32];
	unsigned char tmphash[10];
	errno_t err;
	
	err = _tfopen_s(&FileToHash, filename, TEXT("rb"));
	
	if((err != 0) || (FileToHash == NULL))
	{
		return;
	}
	
	MD5Init(&MDContext);
	
	while((bytes = fread(data, 1, 1024, FileToHash)) != 0)
	{
		MD5Update(&MDContext, data, bytes);
	}
	
	fclose(FileToHash);
	MD5Final(&MDContext);
	
	sprintf(hash, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", 
	MDContext.digest[0],  MDContext.digest[1],  MDContext.digest[2],  MDContext.digest[3],  
	MDContext.digest[4],  MDContext.digest[5],  MDContext.digest[6],  MDContext.digest[7],  
	MDContext.digest[8],  MDContext.digest[9],  MDContext.digest[10],  MDContext.digest[11], 
	MDContext.digest[12],  MDContext.digest[13],  MDContext.digest[14],  MDContext.digest[15]);
	
	fprintf(fp,"%s*", hash);
	_ftprintf(fp, "%s\n", filename);
}
开发者ID:hammackj,项目名称:wintools,代码行数:37,代码来源:md5index.c


示例7: auth8651bGeneralApiTestItem

static int32 auth8651bGeneralApiTestItem(uint32 mode, uint8 * input, uint32 pktLen, uint8 * key, uint32 keyLen) {
	MD5_CTX md5Context;
	SHA1_CTX sha1Context;

	if(rtl8651b_authEngine(mode, input, pktLen, key, keyLen, asicDigest) == FAILED)
		return FAILED;//When authentication engine cannot calculate digest, the testing is surely failed
	authSim(mode, input, pktLen, key, keyLen, simDigest);
	if(memcmp(simDigest, asicDigest, (mode&0x1)? RTL8651B_SHA1_DIGEST_LENGTH: RTL8651B_MD5_DIGEST_LENGTH) != 0) {
		switch(mode) {
			case HASH_MD5:
				MD5Init(&md5Context);
				MD5Update(&md5Context, input, pktLen);
				MD5Final(swDigest, &md5Context);
			break;
			case HASH_SHA1:
				SHA1Init(&sha1Context);
				SHA1Update(&sha1Context, input, pktLen);
				SHA1Final(swDigest, &sha1Context);
			break;
			case HMAC_MD5:
				HMACMD5(input, pktLen, key, keyLen, swDigest);
			break;
			case HMAC_SHA1:
				HMACSHA1(input, pktLen, key, keyLen, swDigest);
			break;
		}
		if(memcmp(simDigest, swDigest, (mode&0x1)? RTL8651B_SHA1_DIGEST_LENGTH: RTL8651B_MD5_DIGEST_LENGTH) != 0)
			displayDigestMismatch(authModeString[mode], input, pktLen, key, keyLen, "SW", swDigest, "SIM", simDigest, (mode&0x1)? RTL8651B_SHA1_DIGEST_LENGTH: RTL8651B_MD5_DIGEST_LENGTH);
		else	 {
			displayDigestMismatch(authModeString[mode], input, pktLen, key, keyLen, "SIM", simDigest, "ASIC", asicDigest, (mode&0x1)? RTL8651B_SHA1_DIGEST_LENGTH: RTL8651B_MD5_DIGEST_LENGTH);
			triggerGpio();
			//rtl8651b_authEngineData(mode, input, pktLen, key, keyLen);
		}
		return FAILED;
	}
	return SUCCESS;	
}
开发者ID:robacklin,项目名称:uclinux-linux,代码行数:37,代码来源:authTest.c


示例8: MD5Init

void ASF_LegacyManager::ComputeDigest()
{
	MD5_CTX context;
	MD5_Digest digest;
	char buffer[40];

	MD5Init ( &context );
	digestStr.clear();
	digestStr.reserve ( 160 );

	for ( int type=0; type < fieldLast; ++type ) {

		if (fields[type].size ( ) > 0 ) {
			snprintf ( buffer, sizeof(buffer), "%d,", type );
			digestStr.append ( buffer );
			MD5Update ( &context, (XMP_Uns8*)fields[type].data(), fields[type].size() );
		}

	}

	if( digestStr.size() > 0 ) digestStr[digestStr.size()-1] = ';';

	MD5Final ( digest, &context );

	size_t in, out;
	for ( in = 0, out = 0; in < 16; in += 1, out += 2 ) {
		XMP_Uns8 byte = digest[in];
		buffer[out]   = ReconcileUtils::kHexDigits [ byte >> 4 ];
		buffer[out+1] = ReconcileUtils::kHexDigits [ byte & 0xF ];
	}
	buffer[32] = 0;

	digestStr.append ( buffer );

	digestComputed = true;

}
开发者ID:hfiguiere,项目名称:exempi,代码行数:37,代码来源:ASF_Support.cpp


示例9: OS_MD5_File

int OS_MD5_File(char * fname, char * output)
{
    FILE *fp;
    MD5_CTX ctx;
    unsigned char buf[1024 +1];
    unsigned char digest[16];
    int n;
    
    memset(output,0, 33);
    buf[1024] = '\0';
    
    fp = fopen(fname,"rb");
    if(!fp)
    {
        return(-1);
    }
    
    MD5Init(&ctx);
    while((n = fread(buf, 1, sizeof(buf) -1, fp)) > 0)
    {
        buf[n] = '\0';
        MD5Update(&ctx,buf,n);
    }
    
    MD5Final(digest, &ctx);
    
    for(n = 0;n < 16; n++)
    {
        snprintf(output, 3, "%02x", digest[n]);
        output+=2;
    }

    /* Closing it */
    fclose(fp);
        
    return(0);
}
开发者ID:alexoslabs,项目名称:ossec-hids,代码行数:37,代码来源:md5_op.c


示例10: get_or_create_fileset_record

bool get_or_create_fileset_record(JCR *jcr)
{
   FILESET_DBR fsr;
   /*
    * Get or Create FileSet record
    */
   memset(&fsr, 0, sizeof(FILESET_DBR));
   bstrncpy(fsr.FileSet, jcr->res.fileset->hdr.name, sizeof(fsr.FileSet));
   if (jcr->res.fileset->have_MD5) {
      struct MD5Context md5c;
      unsigned char digest[MD5HashSize];
      memcpy(&md5c, &jcr->res.fileset->md5c, sizeof(md5c));
      MD5Final(digest, &md5c);
      /*
       * Keep the flag (last arg) set to false otherwise old FileSets will
       * get new MD5 sums and the user will get Full backups on everything
       */
      bin_to_base64(fsr.MD5, sizeof(fsr.MD5), (char *)digest, MD5HashSize, false);
      bstrncpy(jcr->res.fileset->MD5, fsr.MD5, sizeof(jcr->res.fileset->MD5));
   } else {
      Jmsg(jcr, M_WARNING, 0, _("FileSet MD5 digest not found.\n"));
   }
   if (!jcr->res.fileset->ignore_fs_changes ||
       !db_get_fileset_record(jcr, jcr->db, &fsr)) {
      if (!db_create_fileset_record(jcr, jcr->db, &fsr)) {
         Jmsg(jcr, M_ERROR, 0, _("Could not create FileSet \"%s\" record. ERR=%s\n"),
            fsr.FileSet, db_strerror(jcr->db));
         return false;
      }
   }
   jcr->jr.FileSetId = fsr.FileSetId;
   bstrncpy(jcr->FSCreateTime, fsr.cCreateTime, sizeof(jcr->FSCreateTime));
   Dmsg2(119, "Created FileSet %s record %u\n", jcr->res.fileset->hdr.name,
      jcr->jr.FileSetId);
   return true;
}
开发者ID:eneuhauss,项目名称:bareos,代码行数:36,代码来源:job.c


示例11: main

int
main(int argc, char *argv[]) {

  char buffer[1024];
  unsigned char mac[MD5_DIGEST_LENGTH];
  unsigned char buf[MD5_DIGEST_STRING_LENGTH];
  MD5_CTX ctx;
  int ret;

  if (argc != 2) {
    printf("Usage: %s <mac>\n", *argv);
    return 1;
  }

  ret = read(0, buffer, 1024);
  if (ret == -1)
    return 1;

  printf("User message = [%s]\n", buffer);
  printf("User mac = [%s]\n", argv[1]);

  MD5Init(&ctx);
  MD5Update(&ctx, (const u_int8_t *) SECRET, strlen(SECRET));
  MD5Update(&ctx, (const u_int8_t *) buffer, ret);
  MD5Final(mac, &ctx);

  shexdigest(buf, mac);
  printf("[Hint] Expected mac = [%s]\n", buf);

  if (!strcmp((char *)buf, argv[1]) && !lstrstr(buffer, ret, "flag", 4))
    printf("Good!\n");
  else
    printf("Nope\n");

  return 0;
}
开发者ID:Ark444,项目名称:rootcamp,代码行数:36,代码来源:check.c


示例12: nas_rand128

void
nas_rand128(uint8 *rand128)
{
	static int dev_random_fd = -1;
	struct timeval tv;
	struct timezone tz;
	MD5_CTX md5;
	if (dev_random_fd == -1)
		/* Use /dev/urandom because /dev/random, when it works at all,
		 * won't return anything when its entropy pool runs short and
		 * we can't control that.  /dev/urandom look good enough.
		 */
		dev_random_fd = open("/dev/urandom", O_RDONLY|O_NONBLOCK);
	if (dev_random_fd != -1)
		read(dev_random_fd, rand128, 16);
	else {
		gettimeofday(&tv, &tz);
		tv.tv_sec ^= rand();
		MD5Init(&md5);
		MD5Update(&md5, (unsigned char *) &tv, sizeof(tv));
		MD5Update(&md5, (unsigned char *) &tz, sizeof(tz));
		MD5Final(rand128, &md5);
	}
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:24,代码来源:nas_bsd.c


示例13: time_trial

/* Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte
   blocks.
*/
static void time_trial(void)
{
    MD5_CTX context;
    uint32 endTime, startTime;
    unsigned char block[TEST_BLOCK_LEN], digest[16];
    unsigned int i;


    printf
        ("MD5 time trial. Digesting %d %d-byte blocks ...",
         TEST_BLOCK_LEN, TEST_BLOCK_COUNT);

    /* Initialize block */
    for(i = 0; i < TEST_BLOCK_LEN; i++)
        block[i] =(unsigned char)(i & 0xff);

    /* Start timer */
    startTime = VmGetClock();

    /* Digest blocks */
    MD5Init(&context);
    for(i = 0; i < TEST_BLOCK_COUNT; i++)
        MD5Update(&context, block, TEST_BLOCK_LEN);
    MD5Final(digest, &context);

    /* Stop timer */
    endTime = VmGetClock();

    printf(" done\n");
    printf("Digest = ");
    print_digest(digest);
    printf("\nTime = %ld ms\n",(long)(endTime-startTime));
    printf
        ("Speed = %ld bytes/second\n",
        (long)TEST_BLOCK_LEN *(long)TEST_BLOCK_COUNT *(long) 1000/(endTime-startTime));
}
开发者ID:stephen-kun,项目名称:koovox_adk4.0,代码行数:39,代码来源:main.c


示例14: md5sum

bool md5sum(const fs::path &path, md5digest &digest)
{
    try {
        Exiv2::FileIo io(path.file_string());
        if (io.open() != 0)
            return false;
        Exiv2::IoCloser closer(io);

        Exiv2::byte buff[4096];
        MD5_CTX context;
        MD5Init(&context);

        long read_count = io.read(buff, 4096);
        while(read_count) {
            MD5Update(&context, buff, read_count);
            read_count = io.read(buff, 4096);
        }
        MD5Final(digest, &context);
        return true;
    }
    catch (std::exception& ) {
        return false;
    }
}
开发者ID:ahuggel,项目名称:exiv2,代码行数:24,代码来源:organize.cpp


示例15: malloc

//
// this works in lockstep with ::create to populate
// the per chromosome header fields size and md5
// checksum.
//
// It relies on header->elementCount being set to
// the data length loaded so far ... not the ultimate
// reference length.
//
bool GenomeSequence::setChromosomeMD5andLength(uint32_t whichChromosome)
{
    if (whichChromosome>=header->_chromosomeCount) return true;

    ChromosomeInfo *c = &header->_chromosomes[whichChromosome];
    c->size = header->elementCount - c->start;

    MD5_CTX md5Context;
    uint8_t md5Signature[MD5_DIGEST_LENGTH];

    //
    // it's easier to ensure we do this right if we just do it
    // in one big chunk:
    //
    char *md5Buffer = (char *) malloc(c->size);

    MD5Init(&md5Context);

    for (genomeIndex_t i = 0; i < c->size; i ++)
    {
        md5Buffer[i] = (*this)[c->start + i];
    }
    MD5Update(&md5Context, (unsigned char *) md5Buffer, c->size);
    MD5Final((unsigned char *) &md5Signature, &md5Context);
    free(md5Buffer);
    for (int i=0; i<MD5_DIGEST_LENGTH; i++)
    {
        // cheesy but works:
        sprintf(c->md5+2*i, "%02x", md5Signature[i]);
    }
    // redundant, strictly speaking due to sprintf NUL terminating
    // it's output strings, but put it here anyway.
    c->md5[2*MD5_DIGEST_LENGTH] = '\0';

    return false;
}
开发者ID:Griffan,项目名称:FASTQuick,代码行数:45,代码来源:GenomeSequence.cpp


示例16: MDFile

/* Digests an entire file and puts the result into digest.
 */
void MDFile (unsigned char digest[16], char *filename) {
    FILE *file;
    MD5_CTX context;
    int len;
    unsigned char buffer[1024];

    if ((file = fopen (filename, "rb")) == NULL)
	    printf ("%s can't be opened\n", filename);

    else {
	    MD5Init (&context);
	    while ((len = fread (buffer, 1, 1024, file)) != 0)
	        MD5Update (&context, buffer, len);
	    MD5Final (digest, &context);

	    fclose (file);
            /*
	    printf ("MD%d (%s) = ", MD, filename);
	    MDPrint (digest);
	    printf ("\n");
            */
        
    }
}
开发者ID:Ptival,项目名称:Pire2Pire,代码行数:26,代码来源:md5.c


示例17: mppe_crypt

/* Encrypt or decrypt a MPPE message in place */
void
mppe_crypt(unsigned char salt[2],		/* 2 bytes Salt */
	   unsigned char *text,	int text_len,	/* Multiple of 16 bytes String */
	   unsigned char *key, int key_len,	/* Shared secret */
	   unsigned char vector[16],		/* 16 bytes Request Authenticator vector */
	   int encrypt)				/* Encrypt if 1 */
{
	unsigned char b[16], c[16], *p;
	MD5_CTX md5;
	int i;

	/* Initial cipher block is Request Authenticator vector */
	bcopy(vector, c, 16);
	for (p = text; &p[15] < &text[text_len]; p += 16) {
		MD5Init(&md5);
		/* Add shared secret */
		MD5Update(&md5, key, key_len);
		/* Add last cipher block */
		MD5Update(&md5, c, 16);
		/* Add salt */
		if (p == text)
			MD5Update(&md5, salt, 2);
		MD5Final(b, &md5);
		if (encrypt) {
			for (i = 0; i < 16; i++) {
				p[i] ^= b[i];
				c[i] = p[i];
			}
		} else {
			for (i = 0; i < 16; i++) {
				c[i] = p[i];
				p[i] ^= b[i];
			}
		}
	}
}
开发者ID:HarryDLee,项目名称:hiwifi-openwrt-HC5661-HC5761,代码行数:37,代码来源:mppe.c


示例18: MD5Init

CString CryptManager::GetMD5( CString fn )
{
       struct MD5Context md5c;
       unsigned char digest[16];
       int iBytesRead;
       unsigned char buffer[1024];

       RageFile file;
       if( !file.Open( fn, RageFile::READ ) )
       {
               LOG->Warn( "GetMD5: Failed to open file '%s'", fn.c_str() );
               return "";
       }

       MD5Init(&md5c);
       while( !file.AtEOF() && file.GetError().empty() )
       {
               iBytesRead = file.Read( buffer, sizeof(buffer) );
               MD5Update(&md5c, buffer, iBytesRead);
       }
       MD5Final(digest, &md5c);

       return BinaryToHex( digest, sizeof(digest) );
}
开发者ID:TaroNuke,项目名称:openitg,代码行数:24,代码来源:CryptManager.cpp


示例19: AuthDlgProc

//message handler for the client authentication dialog
BOOL CALLBACK AuthDlgProc(HWND hwndDlg, UINT message,
                          WPARAM wParam, LPARAM lParam) {
   switch (message) {
      case WM_INITDIALOG: {
         username[0] = 0;
         cnn.supstr(LAST_USER_SUPVAL, username, sizeof(username));
         SetDlgItemText(hwndDlg, IDC_USERNAME, username);
         return TRUE;
      }
      case WM_COMMAND:
         switch (LOWORD(wParam)) {
         case IDOK: {//OK Button
            char password[64];
            GetDlgItemText(hwndDlg, IDC_USERNAME, username, sizeof(username));
            GetDlgItemText(hwndDlg, IDC_PASSWORD, password, sizeof(password));

            cnn.supset(LAST_USER_SUPVAL, username);

            int pwlen = strlen(password);

            MD5Context ctx;
            MD5Init(&ctx);
            MD5Update(&ctx, (unsigned char*)password, pwlen);
            MD5Final(pwhash, &ctx);
            memset(password, 0, sizeof(password));

            EndDialog(hwndDlg, 1);
            return TRUE;
         }
         case IDCANCEL: //Cancel Button
            EndDialog(hwndDlg, 0);
            return TRUE;
         }
   }
   return FALSE;
}
开发者ID:XVilka,项目名称:htools,代码行数:37,代码来源:collabreate_ui.cpp


示例20: MD5_Plugin

///////////////////////////////////////////////////////////////////////////////
// MD5 of file
//	Input:
//		lpFileName	: full path of plugin
//	Output:
//		sha256		: SHA256 in plain-text (lower case)
//
BOOL MD5_Plugin(char *lpFileName, char *lpOutChecksum)
{
	if (lpFileName == NULL || lpOutChecksum == NULL)
		return FALSE;


	HANDLE hFile = CreateFile(lpFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);

	if (hFile == INVALID_HANDLE_VALUE)
		return FALSE;

	MD5_CTX context;

	MD5Init(&context);

	void *buffer = malloc(64000);

	DWORD dwBytesRead = 0;

	while(ReadFile(hFile, buffer, 64000, &dwBytesRead, NULL) == TRUE)
	{
		if (dwBytesRead == 0)	// end of file?
			break;

		MD5Update(&context, (byte *) buffer, (size_t) dwBytesRead);
	}

	CloseHandle(hFile);
	free(buffer);


	MD5Final(&context);
	hex2ascii(lpOutChecksum, (char *) context.digest, sizeof(context.digest));

	return TRUE;
}
开发者ID:BwRy,项目名称:core-win32,代码行数:43,代码来源:HashUtil.cpp



注:本文中的MD5Final函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MD5Init函数代码示例发布时间:2022-05-30
下一篇:
C++ MCopyStr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap