1+ #include < iostream>
2+ #include < string>
3+ #include < aws/core/Aws.h>
4+ #include < aws/core/utils/HashingUtils.h>
5+ #include < aws/core/utils/memory/stl/AWSString.h>
6+ #include < openssl/opensslv.h>
7+
8+ int main (int argc, char * argv[]) {
9+ // Initialize AWS SDK
10+ Aws::SDKOptions options;
11+ Aws::InitAPI (options);
12+
13+ // Print platform and OpenSSL info
14+ std::cout << " === Platform Information ===" << std::endl;
15+ #ifdef __aarch64__
16+ std::cout << " Architecture: ARM64 (aarch64)" << std::endl;
17+ #elif defined(__x86_64__)
18+ std::cout << " Architecture: x86_64" << std::endl;
19+ #else
20+ std::cout << " Architecture: Unknown" << std::endl;
21+ #endif
22+
23+ std::cout << " OpenSSL version: " << OPENSSL_VERSION_TEXT << std::endl;
24+ std::cout << std::endl;
25+
26+ // Test payload (similar to DeleteObjects XML)
27+ std::string test_payload =
28+ " <?xml version=\" 1.0\" encoding=\" UTF-8\" ?>"
29+ " <Delete>"
30+ " <Object><Key>test-object-1</Key></Object>"
31+ " <Object><Key>test-object-2</Key></Object>"
32+ " </Delete>" ;
33+
34+ std::cout << " === MD5 Calculation Test ===" << std::endl;
35+ std::cout << " Test payload: " << test_payload << std::endl;
36+ std::cout << " Payload size: " << test_payload.length () << " bytes" << std::endl;
37+ std::cout << std::endl;
38+
39+ // Calculate MD5 using AWS SDK
40+ std::cout << " Calling Aws::Utils::HashingUtils::CalculateMD5()..." << std::endl;
41+ auto md5_bytebuffer = Aws::Utils::HashingUtils::CalculateMD5 (test_payload);
42+
43+ std::cout << " MD5 ByteBuffer length: " << md5_bytebuffer.GetLength ()
44+ << " (expected: 16)" << std::endl;
45+
46+ if (md5_bytebuffer.GetLength () == 0 ) {
47+ std::cout << " ERROR: CalculateMD5() returned EMPTY ByteBuffer!" << std::endl;
48+ } else if (md5_bytebuffer.GetLength () == 16 ) {
49+ std::cout << " ✓ SUCCESS: MD5 calculation returned correct length" << std::endl;
50+
51+ // Calculate Base64 encoding
52+ auto base64_md5 = Aws::Utils::HashingUtils::Base64Encode (md5_bytebuffer);
53+ std::cout << " Base64 MD5: " << base64_md5.c_str () << std::endl;
54+ std::cout << " Base64 length: " << base64_md5.length () << " (expected: 24)" << std::endl;
55+ } else {
56+ std::cout << " ERROR: Unexpected MD5 ByteBuffer length!" << std::endl;
57+ }
58+
59+ std::cout << std::endl;
60+
61+ // Cleanup AWS SDK
62+ Aws::ShutdownAPI (options);
63+
64+ return (md5_bytebuffer.GetLength () == 16 ) ? 0 : 1 ;
65+ }
0 commit comments