2 years ago

#11265

test-img

Angga Danar Prasetyo

Converting uint8_t hex to string hex in C

In this case, i use an algorithm hashing to implementating blockchain, and then my algorithm is working properly but the output need to return string. This is my function to try only print the output hexadecimal but i still got an uint8_t:

uint8_t output[32]
void print_output(uint8_t* x){
    int i;
    for (i = 0;i < 32;++i)
        printf("%02x",x[i]);
}
void hashing(char* string) {
    gimli_hash(string, strlen(string), output, 32);
    print_output(output);
}

my output from hashing proses is maybe about like this

uint8_t output = [0x4a, 0xfb, 0x3f, 0xf7, 0x84, 0xc7, 0xad, 0x69, 0x43, 0xd4, 0x9c, 0xf5, 0xda, 0x79, 0xfa, 0xcf, 0xa7, 0xc4, 0x43, 0x4e, 0x1c, 0xe4, 0x4f, 0x5d, 0xd4, 0xb2, 0x8f, 0x91, 0xa8, 0x4d, 0x22, 0xc8]

my expectation output is return string value:

"4afb3ff784c7ad6943d49cf5da79facfa7c4434e1ce44f5dd4b28f91a84d22c8"

I've tried various ways from stackoverflow that recomend from google search but still can't find what I need. I apologize in advance because I'm not good at C programming language. Please help me so i can finish my project from my teacher.

c

string

hash

converters

uint8t

0 Answers

Your Answer

Accepted video resources