The Base64Decode() method wouldn't return original string in certain circumstances, it would remove trailing '\0' of original string.
When the number of bytes to encode is not divisible by three,(for example, if there are only one byte '\o' of input for the last 24-bit block), it would add extra two bytes with value zero so there are three bytes. This three '\0' bytes would encode into 'AA=='. While decoding, Base64Decode() first replace '=' with 'A', which is 'AAAA', and Base64 encoded 'AAAA' would be decoded as '\0\0\0'. And then the method remove all trailing '\0' besides padding NULL added before. So after decoding, the string is different from original string before encoding.
May be the following code fix this bug: