Subject: | Outputs not-quite-valid base64 digests |
The output of the md5_base64() function is not quite right.
Technically, because its length isn't a multiple of 3 characters, it must be padded with '=' signs:
$ perl -MDigest::MD5=md5_base64 -E 'say md5_base64 "Hello"'
ixqZU8RhEpaoJ6v4xHgE1w
$ perl -MDigest::MD5=md5 -MMIME::Base64=encode_base64 -E 'say encode_base64 md5 "Hello"'
ixqZU8RhEpaoJ6v4xHgE1w==
Without this, it doesn't qualify as a valid Base64 encoding for e.g. the Content-MD5 HTTP header. Some HTTP servers reject it, such as Amazon's S3:
<Error><Code>InvalidDigest</Code><Message>The Content-MD5 you specified was invalid.</Message>...
--
Paul Evans