How to detect if a string is Base64Encoded or not?

character-encoding, delphi, encoding

Solution

Best you can do is try to decode it. If the decode fails then the input was not base64 encoded. It the string successfully decodes then the input might have been base64 encoded.

Problem

Which is the best method to detect if a string is Base64Encoded or not (using Delphi)?

Original source