Hi,
your code actually should work (I have tested it, slightly modified because I don't have c++ available on my system, only C),
the only problem is the end of the test input string:
\157147
should be
\157\147
Best regards,
Olivier gg.
Le mercredi 21 avril 2010 18:22:11 UTC+2, Mr. K.V.B.L. a écrit :
I'm kinda going blind with a lot of this API stuff sometimes because C examples are rare for most anything 400. Anyway I can't get a MD5
thing to work and return the right hash. Anyone have a real working example? I was careful to make sure my data was ASCII since most if
not all MD5 test vectors assume ASCII.
// Test string, minus quotes, CCSID 819.
// "The quick brown fox jumps over the lazy dog"
// Expected result for MD5
//9e107d9d372bb6826bd81d3542a419d6
char *test1 = "\124\150\145\40\161\165\151\143\153\40\142\162\157\167\156\40\146\157\170\40\152\165\155\160\163\40\157\166\145\162\40\164\150\145\40\154\141\172\171\40\144\157147";
void CalculateMD5()
{
char Key_verification_Hash[33];
Qc3_Format_ALGD0500_T md5;
error_code_t error_code;
I am trying to do the SHA-256 hashing from a file from the IFS. The hashing is not coming our correctly. Can somebody help?memset(&Key_verification_Hash, 0, sizeof(Key_verification_Hash)); memset(&error_code, 0, sizeof(error_code_t)); error_code.ec_fields.Bytes_Provided = sizeof(error_code_t);
int Length_of_input_data = strlen(test1);
md5.Hash_Alg = Qc3_MD5;
char Cryptographic_service_provider = Qc3_Any_CSP;
Qc3CalculateHash(
test1,
&Length_of_input_data,
"DATA0100",
(char *)&md5,
"ALGD0500",
&Cryptographic_service_provider,
NULL,
Key_verification_Hash,
&error_code);
if (error_code.ec_fields.Bytes_Available != 0) {
cerr << error_code.ec_fields.Exception_Id << endl;
exit(0);
}
else {
cout << "Qc3CalculateHash() seems to have worked." << endl;
char out[100];
memset(out, 0, sizeof(out));
md5_sig_from_string(Key_verification_Hash, out);
cout << out << endl;
to_Base64(Key_verification_Hash, 16, out, 100);
cout << out << endl;
}
}
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 236:52:56 |
Calls: | 6,624 |
Files: | 12,172 |
Messages: | 5,319,839 |