当前位置: 首页>>代码示例>>C++>>正文


C++ print_hex函数代码示例

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


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


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