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

C++ print_hex函数代码示例

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

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



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

示例1: main

int
main(int argc, char *argv[])
{
	if (argc == 2) {
		print_hex(argv[1], strlen(argv[1]));
	} else {
		exit(1);
	}

	return 0;
}
开发者ID:bwalex,项目名称:tcplay_loader,代码行数:11,代码来源:ascii2hex.c


示例2: print_result

void print_result(DRESULT result) {
	switch (result) {
		case 0:
			break;
		default:
			ser_puts(" :( ");
			print_hex((BYTE)result);
			ser_nl();
			break;
	}
}
开发者ID:kitnic,项目名称:ReVerSE-U9,代码行数:11,代码来源:main.c


示例3: transmit_bytes

static  bool
transmit_bytes (const uint8_t *pbtTx, const size_t szTx)
{
  // Show transmitted command
  if (!quiet_output) {
    printf ("Sent bits:     ");
    print_hex (pbtTx, szTx);
  }
  // Transmit the command bytes
  if (nfc_initiator_transceive_bytes (pnd, pbtTx, szTx, abtRx, &szRx, 0) < 0)
    return false;

  // Show received answer
  if (!quiet_output) {
    printf ("Received bits: ");
    print_hex (abtRx, szRx);
  }
  // Succesful transfer
  return true;
}
开发者ID:copacetic,项目名称:tabulator,代码行数:20,代码来源:nfc-anticol.c


示例4: main

int main(int argc, char * const argv[]) {		
	// Let's try sone hashing. 
	unsigned char input[] = {'H', 'a', 'l', 'l', 'o', ' ', 'W', 'e', 'l', 't'}; 

	unsigned char hash[20]; // sha1 hash is always 20 bytes long
	SHA1(input, 10, hash); // (input, input-length, output)
	printf("SHA1 Hash of \"Hallo Welt\": ");
	print_hex(hash, 20);

	return 0;
}
开发者ID:mumogu,项目名称:Sha1-mit-OpenSSL-in-C,代码行数:11,代码来源:main.cpp


示例5: print_bar_pbar

static void print_bar_pbar(struct foo_t* bar, struct pfoo_t* pbar)
{
    print_hex(&bar->i[0], sizeof(int), 1);
    print_hex(&bar->i[2], sizeof(int), 1);
    print_hex(&bar->d[0], sizeof(double), 1);
    print_hex(&bar->d[2], sizeof(double), 1);
    fprintf(stderr, "\n");
    print_hex(&pbar->i[0], sizeof(int), 1);
    print_hex(&pbar->i[1], sizeof(int), 1);
    print_hex(&pbar->d[0], sizeof(double), 1);
    print_hex(&pbar->d[1], sizeof(double), 1);
    fprintf(stderr, "\n");
}
开发者ID:Slbomber,项目名称:ompi,代码行数:13,代码来源:unpack_ooo.c


示例6: challenge_30

void challenge_30()
{
	unsigned char message[128] = "comment1=cooking%20MCs;userdata=foo;"
		"comment2=%20like%20a%20pound%20of%20bacon";
	int mlen = 77, plen;
	unsigned char padded_message[256] = {0};
	memcpy(padded_message, message, 128);
	unsigned char append[16] = ";admin=true";
	int alen = 11;
	unsigned char mac[16], forged_mac[16], test_mac[16];

	print_str("Base MAC");
	md4_keyed_mac(message, strlen((char *) message),
			(unsigned char *) get_static_word(),
			strlen(get_static_word()), mac);
	print_hex(mac, 16);

	print_str("\nForged MAC");
	// Assumes secret length 8, but will be the same for any
	// secret length that doesn't increase or decrease the
	// number of 64 byte blocks in the hash input + padding
	md4_length_extension(mac, mlen + 8 + sha1_pad_length(mlen + 8), append, alen, forged_mac);
	print_hex(forged_mac, 16);

	print_str("\nPlaintext verified by server: ");
	int i;
	for (i = 0; i < 16; ++i) {
		plen = md4_pad(padded_message, mlen, i);
		memcpy(padded_message + plen, append, alen);
		plen += alen;
		md4_keyed_mac(padded_message, plen,
				(unsigned char *) get_static_word(),
				strlen(get_static_word()), test_mac);
		//print_hex(test_mac, 16);
		//print_binary(padded_message, plen);
		if (memcmp(forged_mac, test_mac, 16) == 0) {
			print_hex(test_mac, 16);
			print_binary(padded_message, plen);
		}
	}
}
开发者ID:avanpo,项目名称:cryptopals,代码行数:41,代码来源:set4.c


示例7: main

int main(void) {
	sodium_init();

	printf("HKDF as described in RFC 5869 based on HMAC-SHA512256!\n\n");

	unsigned char output_key[200];
	size_t output_key_length = sizeof(output_key);

	//create random salt
	unsigned char salt[crypto_auth_KEYBYTES];
	randombytes_buf(salt, crypto_auth_KEYBYTES);
	printf("Salt (%i Bytes):\n", crypto_auth_KEYBYTES);
	print_hex(salt, crypto_auth_KEYBYTES, 30);
	putchar('\n');

	//create key to derive from
	unsigned char input_key[100];
	size_t input_key_length = sizeof(input_key);
	randombytes_buf(input_key, input_key_length);
	printf("Input key (%zu Bytes):\n", input_key_length);
	print_hex(input_key, input_key_length, 30);
	putchar('\n');

	//info
	unsigned char* info = (unsigned char*) "This is some info!";
	size_t info_length = sizeof(info);
	printf("Info (%zu Bytes):\n", info_length); //this could also be binary data
	printf("%s\n\n", info);

	int status;
	status = hkdf(output_key, output_key_length, salt, input_key, input_key_length, info, info_length);
	if (status != 0) {
		fprintf(stderr, "ERROR: Failed to derive key. %i\n", status);
		return EXIT_FAILURE;
	}

	printf("Derived key (%zu Bytes):\n", output_key_length);
	print_hex(output_key, output_key_length, 30);
	putchar('\n');
	return EXIT_SUCCESS;
}
开发者ID:gitter-badger,项目名称:molch,代码行数:41,代码来源:hkdf-test.c


示例8: zzuf_destroy_hex

void zzuf_destroy_hex(zzuf_hexdump_t *ctx)
{
    /* Print the last line, if non-empty */
    if (ctx->count & 15)
        print_hex(ctx, (unsigned)(ctx->count & 15));

    /* Print the last offset */
    printf("%08x\n", (uint32_t)ctx->count);

    free(ctx);
    fflush(stdout);
}
开发者ID:0x7678,项目名称:zzuf,代码行数:12,代码来源:hex.c


示例9: main

int main(int argc, char **argv)
{
  int iterations = 10;
  char *salt = "pepper";
  int length = 32;
  char *password;
  int c;

  char *key;
  
  while ((c = getopt(argc, argv, "i:s:l:")) != -1)
    {
      switch (c)
	{
	case 'i':
	  iterations = atoi(optarg);
	  if ( (iterations < 1) || (iterations > 10000000))
	    usage();
	  break;
	case 's':
	  salt = optarg;
	  break;
	case 'l':
	  length = atoi(optarg);
	  if ( (length < 1) || (length > 5000) )
	    usage();
	  break;
	case '?':
	  usage();
	default:
	  abort();
	}
    }

  if (optind != (argc - 1))
    usage();

  password = argv[optind];
  
  key = alloca(length);
  
  pkcs5_derive_key(make_hmac_algorithm(&sha1_algorithm),
		   strlen(password), password,
		   strlen(salt), salt,
		   iterations,
		   length, key);

  printf("Key:");
  print_hex(length, key);
  printf("\n");

  return 0;
}
开发者ID:macssh,项目名称:macssh,代码行数:53,代码来源:pkcs5-test.c


示例10: transmit_bytes

bool transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
{
    //! Show transmitted command
    #ifdef DEBUG_PRINTF
    fprintf(stderr,"Sent bits:     ");
    #endif
    print_hex(pbtTx, szTx);
    //! Transmit the command bytes
    int res;
    if ((res = nfc_initiator_transceive_bytes(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
    {
        return false;
    }
    //! Show received answer
    #ifdef DEBUG_PRINTF
    fprintf(stderr,"Received bits: ");
    #endif
    print_hex(abtRx, res);
    //! Succesful transfer
    return true;
}
开发者ID:UpsilonAudio,项目名称:Projet_NFC,代码行数:21,代码来源:Gestion_NFC.c


示例11: msft_dump

void msft_dump(void)
{
    int i;

    dump_msft_header();

    for(i=0; i < typeinfo_cnt; i++)
        print_hex_id("typeinfo %d offset", i);

    if(header_flags & HELPDLLFLAG)
        print_hex("help dll offset");
    print_offset();
    printf("\n");

    dump_msft_segdir();

    while(!msft_eof) {
        if(!dump_offset())
            print_hex("unknown");
    }
}
开发者ID:evelikov,项目名称:wine,代码行数:21,代码来源:tlb.c


示例12: print_num_x

/** print %x */
static void
print_num_x(char **at, size_t * left, int *ret, unsigned int value,
	    int minw, int precision, int prgiven, int zeropad, int minus,
	    int plus, int space)
{
    char buf[PRINT_DEC_BUFSZ];
    int negative = 0;
    int zero = (value == 0);
    int len = print_hex(buf, (int)sizeof(buf), value);
    print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
	      plus, space, zero, negative, buf, len);
}
开发者ID:dagwieers,项目名称:op,代码行数:13,代码来源:snprintf.c


示例13: main

int main(int argc, char *argv[])
{
    const char sid[] = { 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B };
    const char rid[] = { 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D };
    char id[sizeof(sid)+sizeof(rid)];
    unsigned char strategy = DOMAIN_LOCAL; /*NODE_LOCAL;*/
    ba_handle ba;

    memcpy(id, sid, sizeof(sid));
    memcpy(id+sizeof(sid), rid, sizeof(rid));

    if (argc >= 2)
        strategy = (unsigned char)atoi(argv[1]);

    ba = ba_instance(1);

    ba_publish_scope(ba, sid, sizeof(rid), "", 0,
                     strategy, (void *)0, 0);
    ba_publish_info(ba, rid, sizeof(rid), sid, sizeof(sid),
                    strategy, (void *)0, 0);

    do {
        ba_event ev = ba_event_new();
        unsigned char *_type = NULL, type;
        ba_get_event(ba, ev);
        ba_event_type(ev, &_type);
        type = *_type;
        ba_event_delete(ev);
        if (type == 0)
            goto disconnect;
        if (type == START_PUBLISH)
            break;
    } while (1);

    do {
        char buf[101];
        int nitems;
        unsigned int len;
        printf("What shall I publish, Sir/Madam? (ctrl-d to quit)\n");
        nitems = scanf("%100s", buf); /* XXX */
        if (nitems == EOF)
            break;
        len = strlen(buf);
        print_hex(NULL, buf, len);
        ba_publish_data(ba, id, sizeof(id), strategy, (void *)0, 0, buf, len);
    } while (1);

disconnect:
    ba_disconnect(ba);
    ba_delete(ba);

    return 0;
}
开发者ID:point-h2020,项目名称:point-1.0.0,代码行数:53,代码来源:test_pub.c


示例14: main

int main(int argc, char** argv)
{
	int sock, n;
	char buffer[2048];
	char sendbuf[2048];
	struct ifreq ethreq;
	struct sockaddr_ll saddr;
	int packet_num = 1;
        int i;

        for(i = 0; i < 2048; i++)
        {
            buffer[i] = 0;
            sendbuf[i] = 0;
        }
	if ( (sock=socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)))<0){
		perror("socket");
		exit(1);
	}
	/* Set the network card in promiscuos mode */
	strncpy(ethreq.ifr_name,"nf0",IFNAMSIZ);
	if (ioctl(sock,SIOCGIFINDEX,&ethreq)==-1) {
		perror("ioctl");
		close(sock);
		exit(1);
	}
	
	saddr.sll_family = AF_PACKET;
    saddr.sll_protocol = htons(ETH_P_ALL);
    saddr.sll_ifindex = ethreq.ifr_ifindex;

    if (bind(sock, (struct sockaddr*)(&(saddr)), sizeof(saddr)) < 0)
    {
        perror("Bind");
		close(sock);
		exit(1);
    }
    	sendbuf[0] = 0xfe;sendbuf[1] = 0xca;sendbuf[2] = 0xae;
    	sendbuf[7] = 0x03;
    	sendbuf[32] = 0x0a;sendbuf[33] = 0x0b;sendbuf[34] = 0x0c;sendbuf[35] = 0x0d;
    	sendbuf[36] = 0x1a;sendbuf[37] = 0x1b;sendbuf[38] = 0x1c;sendbuf[39] = 0x1d;
//    	sendbuf[32] = 1;sendbuf[33] = 0;sendbuf[34] = 0xad;sendbuf[35] = 0xde;
    	
 	//if(sendto(sock, sendbuf,100, 0, NULL, 0) <= 0) printf("Error send\n");;
	while (1) {
		n = recvfrom(sock,buffer,2048,0,NULL,NULL);
		printf("Packet%d -----------------------------------------------------\n", packet_num);
		print_hex(buffer, n);
		packet_num++;
	}
	return 0;
}
开发者ID:bamboolll,项目名称:hrav_benchmark,代码行数:52,代码来源:receive.c


示例15: main

int
main(int argc, const char *argv[])
{
  system("clear");
  
  nfc_device *pnd;
  nfc_target nt;

  // Allocate only a pointer to nfc_context
  nfc_context *context;

  // Initialize libnfc and set the nfc_context
  nfc_init(&context);

  // Display libnfc version
  const char *acLibnfcVersion = nfc_version();
  printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);

  // Open, using the first available NFC device.
  pnd = nfc_open(context, NULL);

  if (pnd == NULL) {
    warnx("ERROR: %s", "Unable to open NFC device.");
    return EXIT_FAILURE;
  }
  // Set opened NFC device to initiator mode
  if (nfc_initiator_init(pnd) < 0) {
    nfc_perror(pnd, "nfc_initiator_init");
    exit(EXIT_FAILURE);
  }

  printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
  printf("...\n", nfc_device_get_name(pnd));
  
  while (true){
    // Poll for a ISO14443A (MIFARE) tag
    const nfc_modulation nmMifare = {
      .nmt = NMT_ISO14443A,
      .nbr = NBR_106,
    };
    if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) {
      print_hex(nt.nti.nai.abtUid, nt.nti.nai.szUidLen);
    }
    sleep(1);
  }
    
    // Close NFC device
  nfc_close(pnd);
  // Release the context
  nfc_exit(context);
  return EXIT_SUCCESS;
}
开发者ID:oldu73,项目名称:sblh,代码行数:52,代码来源:nfcc001.c


示例16: ikev2_pld_certreq

int
ikev2_pld_certreq(struct iked *env, struct ikev2_payload *pld,
    struct iked_message *msg, size_t offset, size_t left)
{
	struct iked_sa			*sa = msg->msg_sa;
	struct ikev2_cert		 cert;
	u_int8_t			*buf;
	ssize_t				 len;
	u_int8_t			*msgbuf = ibuf_data(msg->msg_data);

	if (ikev2_validate_certreq(msg, offset, left, pld, &cert))
		return (-1);
	offset += sizeof(cert);

	buf = msgbuf + offset;
	len = betoh16(pld->pld_length) - sizeof(*pld) - sizeof(cert);

	log_debug("%s: type %s length %zd",
	    __func__, print_map(cert.cert_type, ikev2_cert_map), len);

	/* This will actually be caught by earlier checks. */
	if (len < 0) {
		log_debug("%s: invalid certificate request length", __func__);
		return (-1);
	}

	print_hex(buf, 0, len);

	if (!ikev2_msg_frompeer(msg))
		return (0);

	if (cert.cert_type == IKEV2_CERT_X509_CERT) {
		if (!len || (len % SHA_DIGEST_LENGTH) != 0) {
			log_debug("%s: invalid certificate request", __func__);
			return (-1);
		}
	}

	if (msg->msg_sa == NULL)
		return (-1);

	/* Optional certreq for PSK */
	if (sa->sa_hdr.sh_initiator)
		sa->sa_stateinit |= IKED_REQ_CERT;
	else
		sa->sa_statevalid |= IKED_REQ_CERT;

	ca_setreq(env, &sa->sa_hdr, &sa->sa_policy->pol_localid,
	    cert.cert_type, buf, len, PROC_CERT);

	return (0);
}
开发者ID:toddfries,项目名称:OpenBSD-sbin-patches,代码行数:52,代码来源:ikev2_pld.c


示例17: print_hex

void	print_hex(int nb)
{
	char c;

	if (nb / 16)
		print_hex(nb / 16);
	nb %= 16;
	if (nb >= 0 && nb <= 9)
		c = nb + '0';
	else if (nb >= 10 && nb <= 15)
		c = nb + 87;
	write(1, &c, 1);
}
开发者ID:jmunozz,项目名称:42-1,代码行数:13,代码来源:print_hex.c


示例18: pkt_process

void pkt_process(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes)
{

	printf("\n\n ############ One New Packet ############### \n");
	printf("Capture pcaket time is %s", ctime((const time_t *)&h->ts.tv_sec));
	printf("Cpature pcaket length is %d\n", h->caplen);
	printf("Pcaket real length is %d\n", h->len);

	length = h->caplen;
	print_hex((char *)bytes, length);

	process_ether((char *)bytes);
}
开发者ID:liuzixinlzx0,项目名称:First_Project,代码行数:13,代码来源:main.c


示例19: main

int main()
{
    int file;
    int rc = 0;

    //static char buf[] = {0x03, 0x07, 0x1B, 0x01, 0x00, 0x00, 0x27,
    //0x47};



    if ((file = open(filename, O_RDWR)) < 0) {
        /* ERROR HANDLING: you can check errno to see what went wrong */
        perror("Failed to open the i2c bus");
        exit(1);
    }

    if(sizeof(buf) != write(file,buf,sizeof(buf))){
        perror("Write failed\n");
        exit(1);
    }
    else{
        printf("Wrote %lu bytes\n", sizeof(buf));
    }

    if (sizeof(recv_buf) != read(file,recv_buf,sizeof(recv_buf))){
        perror("Read failed\n");
        exit(1);
    }
    else{
        printf("Read %lu bytes\n", sizeof(recv_buf));
        print_hex("Received data", recv_buf, sizeof(recv_buf));
    }

    if (test_single_byte_read(file) != 0){
        printf("Single byte read failed\n");
        rc = 1;
        goto close_exit;
    }

    if (test_multiple_open()){
        printf("Multiple open failed\n");
        rc = 1;
        goto close_exit;
    }

 close_exit:

    close(file);

    return rc;
}
开发者ID:cryptotronix,项目名称:atsha204-i2c,代码行数:51,代码来源:test.c


示例20: read_data

/*Reads data from inputfile/stdin and prepares the input for hexdump conversion. 
Reads 1 byte at a time and when it reaches 16, passes it to the hexdump function.  */
void read_data(FILE *fp)
{

	unsigned char * buff1 = (unsigned char*) malloc(16); // buffer to read input.
	unsigned char * buff2 = (unsigned char *)malloc(16);
	int i =0, k;

	if(buff1== NULL)
	{
		fprintf(stderr, "Error: malloc() malfunctioning.\n");
	}
	while(!feof(fp))
	{
		fread(&buff1[i], sizeof(char) , 1, fp);
		i++;
		if(i>=16)
		{	
			print_hex(buff1,i);
			i=0;
			for(k=0;k<16;k++)
				buff1[k] = '\0';
		 // when buffer reaches 16, clear the buffer and read next 16 characters.
		}
		
		
	}

	if(i) // if buffer is less than 16 and input has reached its end. 
	{
		print_hex(buff1,i-1);
		i=0;
	}

	fclose(fp);
	free(buff1);
	free(buff2);

}
开发者ID:samyuktr,项目名称:Simulation_of_openssl_commands_in_C,代码行数:40,代码来源:set1.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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