d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Comparing Bytes?
Add Reply New Topic New Poll
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Sep 26 2014 02:49pm
This is in C btw.

I'm using the open.ssl lib to find the key value for an encrypted string for an encrpytion.

I know that the expected output for the encrypted string is some hex value

http://www.openssl.org/docs/crypto/EVP_EncryptInit.html

Following the above link, encrytpupdate places the cipher into an unsigned char value.

I have to compare the expected output to the cipher output to see if the keys correct, by going byte by byte, (aka does the expected output match the output from the cipher)

Question :- : Kinda confused on how to take the expected hex output and compare it to the unsigned char cipher output. Like how are you supposed to compare them byte by byte?

This post was edited by lopelurag on Sep 26 2014 02:55pm
Member
Posts: 1,241
Joined: Jun 25 2011
Gold: Locked
Sep 26 2014 03:04pm
Could you provide an actual example of a hex value and the unsigned char buffer to compare it to?
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Sep 26 2014 04:22pm
Use memcmp to compare. You need a buffer with data you're going compare your result to.
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Sep 26 2014 10:15pm
Yea I figured it out sorry for not replying.

Thanks for the insight though

Quote (KrzaQ2 @ Sep 26 2014 06:22pm)
Use memcmp to compare. You need a buffer with data you're going compare your result to.


Didn't think of mem compare, I assume you'd have to malloc for it to be used?
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Sep 27 2014 03:00am
No, you do not.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll