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

C++ MD5_Final函数代码示例

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

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



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

示例1: md5_identity

char * md5_identity(void *data, int len)
{
    unsigned char hash[16];
    char* result;
    int ptr,i;

    result = (char*)malloc(sizeof(char)*512);
    memset(result, 0, sizeof(result));
    MD5_CTX ctx;
    MD5_Init(&ctx);
    MD5_Update(&ctx,(char*)data,len);
    MD5_Final(hash,&ctx);

    ptr = 0;
    for(i=0;i<16;i++)
    {
        ptr += sprintf(result+ptr, "%02x", hash[i]);
    }
    return result;
}
开发者ID:Wizmann,项目名称:Utils,代码行数:20,代码来源:hdd_identity.c


示例2: sizeof

ClientWardenModule* WardenWin::GetModuleForClient()
{
    ClientWardenModule *mod = new ClientWardenModule;

    uint32 length = sizeof(Module.Module);

    // data assign
    mod->CompressedSize = length;
    mod->CompressedData = new uint8[length];
    memcpy(mod->CompressedData, Module.Module, length);
    memcpy(mod->Key, Module.ModuleKey, 16);

    // md5 hash
    MD5_CTX ctx;
    MD5_Init(&ctx);
    MD5_Update(&ctx, mod->CompressedData, length);
    MD5_Final((uint8*)&mod->Id, &ctx);

    return mod;
}
开发者ID:ProjectSkyfire,项目名称:SkyFire.548,代码行数:20,代码来源:WardenWin.cpp


示例3: sizeof

ClientWardenModule *WardenMac::GetModuleForClient(WorldSession *session)
{
    ClientWardenModule *mod = new ClientWardenModule;

    uint32 len = sizeof(Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data);

    // data assign
    mod->CompressedSize = len;
    mod->CompressedData = new uint8[len];
    memcpy(mod->CompressedData, Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data, len);
    memcpy(mod->Key, Module_0DBBF209A27B1E279A9FEC5C168A15F7_Key, 16);
        
    // md5 hash
    MD5_CTX ctx;
    MD5_Init(&ctx);
    MD5_Update(&ctx, mod->CompressedData, len);
    MD5_Final((uint8*)&mod->ID, &ctx);

    return mod;
}
开发者ID:romseguy,项目名称:Trinitycore_Azshara_2.4.3,代码行数:20,代码来源:WardenMac.cpp


示例4: md5sum

string md5sum(const char * str, int len)
{
	int n;
    MD5_CTX ctx;
    char buf[SLICECAP];
    unsigned char out[MD5_DIGEST_LENGTH];
    string md5str;

	MD5_Init(&ctx);
	MD5_Update(&ctx, str, len);
    MD5_Final(out, &ctx);

    for(n = 0; n< MD5_DIGEST_LENGTH; n++)
	{
		snprintf(buf, SLICECAP, "%02x", out[n]);
		md5str += buf;
	}

    return md5str;     
}
开发者ID:Wenchy,项目名称:tinyFTP,代码行数:20,代码来源:common.cpp


示例5: get_signature

// computes an RSA-MD5 signature over 'buf' using 'priv_key'
// signature data is returned is 'sig_buf' which should be at least
// SIGNATURE_LEN bytes in size.  
// Method returns 0 on success.   
int get_signature(char *buf, unsigned int buf_size, RSA *priv_key,
                   unsigned char *sig_buf, unsigned int *sig_len) {

  unsigned char digest[16];
  unsigned int digest_len = 16;
  MD5_CTX md5;
  MD5_Init(&md5);
  MD5_Update(&md5, (unsigned char*)buf, buf_size);
  MD5_Final(digest, &md5);

  int ret_val = RSA_sign(NID_md5, digest, digest_len, 
			sig_buf, sig_len, priv_key);
  if(!ret_val) {
      unsigned long e = ERR_get_error();
      DPRINTF(DEBUG_ERROR,"RSA_sign error: %s", ERR_error_string(e, buf));
      return 1;
  }
 
  return 0;
}
开发者ID:katmagic,项目名称:perspectives-notary-server,代码行数:24,代码来源:notary_crypto.c


示例6: cipher_set_key_string

/*
 * Selects the cipher, and keys if by computing the MD5 checksum of the
 * passphrase and using the resulting 16 bytes as the key.
 */
int
cipher_set_key_string(struct sshcipher_ctx *cc, struct sshcipher *cipher,
    const char *pphrase, int do_encrypt)
{
	MD5_CTX md;
	u_char digest[16];
	int ret = SSH_ERR_LIBCRYPTO_ERROR;

	if (MD5_Init(&md) != 1 ||
	    MD5_Update(&md, (const u_char *)pphrase, strlen(pphrase)) != 1 ||
	    MD5_Final(digest, &md) != 1)
		goto out;

	ret = cipher_init(cc, cipher, digest, 16, NULL, 0, do_encrypt);

 out:
	memset(digest, 0, sizeof(digest));
	memset(&md, 0, sizeof(md));
	return ret;
}
开发者ID:mpitzl,项目名称:libopenssh,代码行数:24,代码来源:cipher.c


示例7: md5

//Return value is on the heap.
char* md5(const char *filename) {

	//Open the input file.
	FILE *in_file = fopen(filename, "rb");

	if (!in_file) {
		printf ("%s can't be opened.\n", filename);
		return NULL;
	}

	//Initialise the md5 function.
	MD5_CTX md_context;
	MD5_Init (&md_context);
	
	//Read in the data from the file and feed it to the md5 function.
	int bytes;
	unsigned char data[1024];

	while ((bytes = fread(data, 1, 1024, in_file)) != 0) {
		MD5_Update(&md_context, data, bytes);
	}

	//Recieve the final md5 value inside c.
	unsigned char c[MD5_DIGEST_LENGTH];
	MD5_Final(c,&md_context);

	//Allocate memory for the return value.
	char tmp[2];
	char *hash = malloc((MD5_DIGEST_LENGTH * 2) + 1);

	//Format the md5 digits as chars.
	for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
		sprintf(tmp, "%02x", c[i]);
		memcpy(hash+(i*2), tmp, 2);
	}

	hash[MD5_DIGEST_LENGTH*2] = '\0';
	fclose (in_file);

	return hash;
}
开发者ID:klampworks,项目名称:md5me,代码行数:42,代码来源:main.c


示例8: ssl3_PRF

int ssl3_PRF( const u_char* secret, uint32_t secret_len, 
		const u_char* random1, uint32_t random1_len,
		const u_char* random2, uint32_t random2_len,
		u_char* out, uint32_t out_len )
{
	MD5_CTX md5;
	SHA_CTX sha;
	u_char buf[20];
	uint32_t off;
	u_char i;

	if( !out ) return NM_ERROR( DSSL_E_INVALID_PARAMETER );

	for( off=0, i = 1; off < out_len; off+=16, ++i )
	{
		u_char md5_buf[16];
		uint32_t cnt;
		uint32_t j;

		MD5_Init(&md5);
		SHA1_Init(&sha);

		/* salt: A, BB, CCC,  ... */
		for( j=0; j < i; j++ ) buf[j]='A' + (i-1);

		SHA1_Update( &sha, buf, i );
		if( secret ) SHA1_Update( &sha, secret, secret_len );
		SHA1_Update( &sha, random1, random1_len );
		SHA1_Update( &sha, random2, random2_len );
		SHA1_Final( buf, &sha );

		MD5_Update( &md5, secret, secret_len );
		MD5_Update( &md5, buf, 20 );
		MD5_Final( md5_buf, &md5 );

		cnt = out_len - off < 16 ? out_len - off : 16;
		memcpy( out + off, md5_buf, cnt );
	}

	return DSSL_RC_OK;
}
开发者ID:gamelinux,项目名称:snort_preprocessor_dssl,代码行数:41,代码来源:ssl_utils.c


示例9: respond_to_rsa_challenge

/*
 * Computes the proper response to a RSA challenge, and sends the response to
 * the server.
 */
static void
respond_to_rsa_challenge(struct ssh *ssh, BIGNUM * challenge, RSA * prv)
{
    u_char buf[32], response[16];
    MD5_CTX md;
    int r, len;

    /* Decrypt the challenge using the private key. */
    /* XXX think about Bleichenbacher, too */
    if ((r = rsa_private_decrypt(challenge, challenge, prv)) != 0) {
        ssh_packet_disconnect(ssh,  "%s: rsa_private_decrypt: %s",
                              __func__, ssh_err(r));
    }

    /* Compute the response. */
    /* The response is MD5 of decrypted challenge plus session id. */
    len = BN_num_bytes(challenge);
    if (len <= 0 || (u_int)len > sizeof(buf))
        ssh_packet_disconnect(ssh,
                              "respond_to_rsa_challenge: bad challenge length %d", len);

    memset(buf, 0, sizeof(buf));
    BN_bn2bin(challenge, buf + sizeof(buf) - len);
    MD5_Init(&md);
    MD5_Update(&md, buf, 32);
    MD5_Update(&md, session_id, 16);
    MD5_Final(response, &md);

    debug("Sending response to host key RSA challenge.");

    /* Send the response back to the server. */
    if ((r = sshpkt_start(ssh, SSH_CMSG_AUTH_RSA_RESPONSE)) != 0 ||
            (r = sshpkt_put(ssh, &response, sizeof(response))) != 0 ||
            (r = sshpkt_send(ssh)) != 0)
        fatal("%s: %s", __func__, ssh_err(r));
    ssh_packet_write_wait(ssh);

    memset(buf, 0, sizeof(buf));
    memset(response, 0, sizeof(response));
    memset(&md, 0, sizeof(md));
}
开发者ID:hshoexer,项目名称:libopenssh,代码行数:45,代码来源:sshconnect1.c


示例10: md5

void md5(FILE * f)
{
 MD5_CTX ctx;
 unsigned char tab[MD5_DIGEST_LENGTH];
 MD5_Init(&ctx);
 unsigned char bufor[size];
 int read;
 
 while (!feof(f))
       {
        read = fread(bufor, 1, size, f);
        MD5_Update(&ctx, bufor, read);
       }
 
 MD5_Final(tab, &ctx);
 
 int i;
 for (i = 0; i < MD5_DIGEST_LENGTH; i++)
     printf("%02x", tab[i]);
 printf("\n");   
}
开发者ID:kgadek,项目名称:kpfp,代码行数:21,代码来源:MD5SHA1.c


示例11:

bool	Checksum::get_final(struct_file* file) {
	if ( file == NULL )
		return false;

	if ( SHA1_Final(sha1, &sha1_ctx) == 0 || MD5_Final(md5, &md5_ctx) == 0 ) {
		// error !
		return false;
	}

	file->sha1.clear();
	for ( int i = 0 ; i < SHA_DIGEST_LENGTH ; ++i ) {
		file->sha1.append(QString::number(sha1[i], 16));
	}

	// FIXME: the MD5 sum is wrong:w
	file->md5.clear();
	for ( int i = 0 ; i < MD5_DIGEST_LENGTH ; ++i ) {
		file->md5.append(QString::number(md5[i], 16));
	}
	return true;
}
开发者ID:pombredanne,项目名称:forensics-data-extractor,代码行数:21,代码来源:checksum.cpp


示例12: GetSubscriberMD5

// Function which calculates MD5 for comparison with Response Authenticator
void GetSubscriberMD5(BYTE subResponseAuth[MD5_DIGEST_LENGTH], RADIUS_PACKET *aaaData, SUBSCRIBER *sub) {

	int i, j;
	BYTE hash[MAX_ARGUMENT_LENGTH];
	MD5_CTX context;

	// Init MD5
	MD5_Init(&context);
	// Create string to be hashed and execute MD5 hashing
	bzero(hash, MAX_ARGUMENT_LENGTH);
	hash[0] = aaaData->code;
	hash[1] = aaaData->identifier;
	memcpy(hash + 2, (unsigned char *)&aaaData->length, 2);
	memcpy(hash + 4, sub->aaaAuthenticator, 16);
	memcpy(hash + 20, aaaData->options, htons(aaaData->length) - RADIUS_HEADER_LENGTH);
	memcpy(hash + ntohs(aaaData->length), Radius_secret, strlen(Radius_secret));
	MD5_Update (&context, hash, ntohs(aaaData->length) + strlen(Radius_secret));
	MD5_Final (subResponseAuth, &context);

	return;
}
开发者ID:OpenBRAS,项目名称:OpenBRAS,代码行数:22,代码来源:functions_tree.c


示例13: verify_password

// Password is did_u_really_reverse_me
int verify_password(char *pass) {
	MD5_CTX c;
	unsigned char digest[16] = {
		0x87, 0xe0, 0xbe, 0x2f, 0x4f, 0x39, 0x86, 0x29, 
		0x5d, 0x86, 0xe3, 0x27, 0xaf, 0x53, 0xee, 0xd2
	};
	unsigned char pass_digest[16];
	int i;

	MD5_Init(&c);
	MD5_Update(&c, pass, strlen(pass));
	MD5_Final(pass_digest, &c);

	for (i = 0; i < 16; i++) {
		if (digest[i] != pass_digest[i]) {
			return -1;
		}
	}

	return 0;
}
开发者ID:CSGO-2016,项目名称:Reverse,代码行数:22,代码来源:bin1.c


示例14: malloc

unsigned char * Condor_MD_MAC::computeOnce(unsigned char * buffer, 
                                           unsigned long   length, 
                                           KeyInfo       * key)
{
#ifdef HAVE_EXT_OPENSSL
    unsigned char * md = (unsigned char *) malloc(MAC_SIZE);
    MD5_CTX  context;

    MD5_Init(&context);

    MD5_Update(&context, key->getKeyData(), key->getKeyLength());

    MD5_Update(&context, buffer, length);

    MD5_Final(md, &context);

    return md;
#else
    return NULL;
#endif
}
开发者ID:AlanDeSmet,项目名称:htcondor,代码行数:21,代码来源:condor_md.cpp


示例15: generate_data

void generate_data( dcp_info_t * info ) { 
    // init static random generator
    srand(STATIC_SEED);

    MD5_CTX ctx;
    int idx;
    for( idx=0; idx<info->nbuffer; ++idx) {
        MD5_Init(&ctx);
        uintptr_t ptr = (uintptr_t) info->buffer[idx];
        uintptr_t ptr_e = (uintptr_t)info->buffer[idx] + (uintptr_t)info->size[idx];
        while ( ptr < ptr_e ) {
            unsigned int rui = (unsigned int) rand();
            int init_size = ( (ptr_e - ptr) > UI_UNIT ) ? UI_UNIT : ptr_e-ptr;
            memcpy((void*)ptr, &rui, init_size);
            MD5_Update( &ctx, (void*)ptr, init_size); 
            ptr += init_size;
        }
        assert( ptr == ptr_e );
        MD5_Final(info->hash[idx], &ctx);
    }
}
开发者ID:leobago,项目名称:fti,代码行数:21,代码来源:diff_test_func.c


示例16: compute_session_id

void
compute_session_id(u_char session_id[16],
    u_char cookie[8],
    BIGNUM* host_key_n,
    BIGNUM* session_key_n)
{
	u_int host_key_bytes = BN_num_bytes(host_key_n);
	u_int session_key_bytes = BN_num_bytes(session_key_n);
	u_int bytes = host_key_bytes + session_key_bytes;
	u_char *buf = xmalloc(bytes);
	MD5_CTX md;

	BN_bn2bin(host_key_n, buf);
	BN_bn2bin(session_key_n, buf + host_key_bytes);
	MD5_Init(&md);
	MD5_Update(&md, buf, bytes);
	MD5_Update(&md, cookie, 8);
	MD5_Final(session_id, &md);
	memset(buf, 0, bytes);
	xfree(buf);
}
开发者ID:M31MOTH,项目名称:attacks,代码行数:21,代码来源:mpaux.c


示例17: crypt_all

static int crypt_all(int *pcount, struct db_salt *salt)
{
	int count = *pcount;
	int index = 0;

#ifdef _OPENMP
#pragma omp parallel for
#endif
#if defined(_OPENMP) || MAX_KEYS_PER_CRYPT > 1
	for (index = 0; index < count; index++)
#endif
	{
		unsigned char hash[16];
		MD5_CTX ctx;
		MD5_Init(&ctx);
		MD5_Update(&ctx, saved_key[index], strlen(saved_key[index]));
		MD5_Final(hash, &ctx);
		hex_encode(hash, 16, (unsigned char*)crypt_out[index]);
	}
	return count;
}
开发者ID:mimaun,项目名称:Rose,代码行数:21,代码来源:md5_broken_fmt_plug.c


示例18: stun_produce_integrity_key_str

int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *upwd, u08bits *key)
{
	MD5_CTX ctx;
	size_t ulen = strlen((s08bits*)uname);
	size_t rlen = strlen((s08bits*)realm);
	size_t plen = strlen((s08bits*)upwd);
	u08bits *str = (u08bits*)malloc(ulen+1+rlen+1+plen+1);

	strcpy((s08bits*)str,(s08bits*)uname);
	str[ulen]=':';
	strcpy((s08bits*)str+ulen+1,(s08bits*)realm);
	str[ulen+1+rlen]=':';
	strcpy((s08bits*)str+ulen+1+rlen+1,(s08bits*)upwd);

	MD5_Init(&ctx);
	MD5_Update(&ctx,str,ulen+1+rlen+1+plen);
	MD5_Final(key,&ctx);
	free(str);

	return 0;
}
开发者ID:arnaudcoquelet,项目名称:oss_core,代码行数:21,代码来源:ns_turn_utils.c


示例19: gen_md5

int gen_md5(headers_t *headers, char *target) {
    unsigned long key1 = parse_hixie76_key(headers->key1);
    unsigned long key2 = parse_hixie76_key(headers->key2);
    char *key3 = headers->key3;

    MD5_CTX c;
    char in[HIXIE_MD5_DIGEST_LENGTH] = {
        key1 >> 24, key1 >> 16, key1 >> 8, key1,
        key2 >> 24, key2 >> 16, key2 >> 8, key2,
        key3[0], key3[1], key3[2], key3[3],
        key3[4], key3[5], key3[6], key3[7]
    };

    MD5_Init(&c);
    MD5_Update(&c, (void *)in, sizeof in);
    MD5_Final((void *)target, &c);

    target[HIXIE_MD5_DIGEST_LENGTH] = '\0';

    return 1;
}
开发者ID:gvsurenderreddy,项目名称:theqvd,代码行数:21,代码来源:websocket.c


示例20: get_full_cksum

static int get_full_cksum(struct file *f, FILE **fp)
{
	size_t s=0;
	MD5_CTX md5;
	static char buf[FULL_CHUNK];
	unsigned char checksum[MD5_DIGEST_LENGTH+1];

	if(*fp) fseek(*fp, 0, SEEK_SET);
	else if(!(*fp=open_file(f)))
	{
		f->full_cksum=0;
		return 0;
	}

	if(!MD5_Init(&md5))
	{
		logp("MD5_Init() failed\n");
		return -1;
	}

	while((s=fread(buf, 1, FULL_CHUNK, *fp))>0)
	{
		if(!MD5_Update(&md5, buf, s))
		{
			logp("MD5_Update() failed\n");
			return -1;
		}
		if(s<FULL_CHUNK) break;
	}

	if(!MD5_Final(checksum, &md5))
	{
		logp("MD5_Final() failed\n");
		return -1;
	}

	memcpy(&(f->full_cksum), checksum, sizeof(unsigned));

	return 0;
}
开发者ID:kaptk2,项目名称:burp,代码行数:40,代码来源:bedup.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ MD5_Init函数代码示例发布时间:2022-05-30
下一篇:
C++ MD5Update函数代码示例发布时间: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