@@ -68,6 +68,27 @@ TEST(OpensslUtilTest, Base64DecodePadding) {
6868 EXPECT_THAT (UrlsafeBase64Decode (" QUJDRA==" ), ElementsAre (' A' , ' B' , ' C' , ' D' ));
6969}
7070
71+ TEST (OpensslUtilTest, MD5HashEmpty) {
72+ auto const actual = MD5Hash (" " );
73+ // I used this command to get the expected value:
74+ // /bin/echo -n "" | openssl md5
75+ auto const expected =
76+ std::vector<std::uint8_t >{0xd4 , 0x1d , 0x8c , 0xd9 , 0x8f , 0x00 , 0xb2 , 0x04 ,
77+ 0xe9 , 0x80 , 0x09 , 0x98 , 0xec , 0xf8 , 0x42 , 0x7e };
78+ EXPECT_THAT (actual, ElementsAreArray (expected));
79+ }
80+
81+ TEST (OpensslUtilTest, MD5HashSimple) {
82+ auto const actual = MD5Hash (" The quick brown fox jumps over the lazy dog" );
83+ // I used this command to get the expected value:
84+ // /bin/echo -n "The quick brown fox jumps over the lazy dog" |
85+ // openssl md5 -binary | openssl base64
86+ auto const expected =
87+ std::vector<std::uint8_t >{0x9e , 0x10 , 0x7d , 0x9d , 0x37 , 0x2b , 0xb6 , 0x82 ,
88+ 0x6b , 0xd8 , 0x1d , 0x35 , 0x42 , 0xa4 , 0x19 , 0xd6 };
89+ EXPECT_THAT (actual, ElementsAreArray (expected));
90+ }
91+
7192} // namespace
7293} // namespace internal
7394} // namespace STORAGE_CLIENT_NS
0 commit comments