How to assign a hexadecimal value to an unsigned char variable in a C program [closed]

That’s a string of 32 characters, being hexadecimal digits. That makes 16 bytes, or 128 bits.

m0skit0 told you how to store it in a string. If you actually want to store that in an integer, you’d need something like unsigned long long intvar = strtoull( stringvar, NULL, 16 ) – provided “long long” on your machine can stomach 128 bits.

But what you want is something completely different, which became clear only after you linked to that other question. (It’s really bad to take something out of context like that, especially if you are confused about what you’re actually doing.)

If you take a look at the API documentation, you will see that the parameter you are looking at is a pointer to DES_cblock. That’s not a string, and not an integer. Have a look at seed and ivsetup in that other question, how they are initialized, and think for a minute.

Leave a Comment