Thank you.
Matej Kurpel wrote: > > On 5. 2. 2011 16:31, lu_hernan wrote: >> Thank you for answering. >> >> The file does not include any CR or LF but I have noticed that is saved >> in >> UTF-8. Does it has anything to do with the problem? > Maybe. Some UTF-8 files can contain a Byte Order Mark (or BOM) which > consists of 3 bytes at the very beginning of the file. Most editors > don't show them up but you can clearly see them when looking at the file > in a hex-editor. >> If I read the file with a program with the code below the result is the >> same >> as the command line but, if I take the content of a file and put it in >> const >> unsigned char data[] it does not. >> >> My program will generate a string that has to be signed (md5 and RSA >> key). >> Which method will assure that I have a valid signed string: >> Write that string to a file and read it back to sign it? >> Or pass the string as an argument to a function and sign it? ( this is I >> would like to do but digest is different) >> >> TIA >> >> Luis Hernandez >> >> >> >> Dave Thompson-5 wrote: >>>> From: owner-openssl-us...@openssl.org On Behalf Of lu_hernan >>>> Sent: Friday, 04 February, 2011 19:14 >>>> openssl dgst -md5 sometextdata.txt >>>> >>>> it gives an answer XYZ >>>> >>>> but using this code en visual c++: >>>> const unsigned char data[]="text from file: sometextdata.txt"; >>>> unsigned char md[MD5_DIGEST_LENGTH]; >>>> MD5(data, strlen(data), md); >>>> >>>> it gives ABC as result. >>>> >>> Make sure the data is exactly byte-for-byte the same. >>> In particular, does the file have a CR-LF, or maybe just LF, >>> at the end? My ancient MSVC++6 (circa 1998) has an option >>> on File / Open: OpenAs=Binary . If that or something similar >>> is available, it should show exactly what's in the file. >>> If not do a simple program like: >>> >>> #include<stdio.h> >>> int main(void){ >>> FILE * fp = fopen ("sometextdata.txt", "rb"); /* b matters on Win */ >>> unsigned char buff[99999]; int i, n = fread (buff,1,sizeof buff, fp); >>> for( i = 0; i< n; i++ ) printf ("%c%02X", " \n"[!(i&0xF)], buff[i]); >>> printf ("\n"); fclose (fp); return 0; } >>> >>> >>> ______________________________________________________________________ >>> OpenSSL Project http://www.openssl.org >>> User Support Mailing List openssl-users@openssl.org >>> Automated List Manager majord...@openssl.org >>> >>> > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-users@openssl.org > Automated List Manager majord...@openssl.org > > -- View this message in context: http://old.nabble.com/command-line-resul-ok-but-not-c%2B%2B-code-tp30849236p30873792.html Sent from the OpenSSL - User mailing list archive at Nabble.com. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org