123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include <stdio.h>
- #include <stdlib.h>
- #include "io.h"
- void input_hex_to_bits(bit_array *array, int count)
- {
- printf("Input %d Int16 of Key in hex:\n", count);
- uint16_t tmp = 0;
- short index = 0;
- for (short i = 0; i < count; i++) {
- int num = scanf("%hx", &tmp);
- if (num != 1) {
- printf("Wrong Format, please retry.\n");
- exit(1);
- }
- hex2bits(array, index, tmp);
- index += 16;
- }
- }
- void input_hex_to_int16(uint16_t *array, int count)
- {
- printf("Input %d Int16 of Original Text in hex:\n", count);
- for (short i = 0; i < count; i++) {
- int num = scanf("%hx", &array[i]);
- if (num != 1) {
- printf("Wrong Format, please retry.\n");
- exit(1);
- }
- }
- }
- void print_bits_array(bit_array *array, int len)
- {
- for (int i = 0; i < len; i++) {
- printf("%hx ", get_bit(array, i));
- }
- putchar('\n');
- }
- void print_uint16_array(uint16_t *array, int len, const char *end)
- {
- for (int i = 0; i < len; i++) {
- if (i != 0 && i % 8 == 0) {
- putchar('\n');
- }
- printf("%hx", array[i]);
- printf(end);
- }
- putchar('\n');
- }
|