Strictly speaking, there is no way to check it up. You can only do some guesswork. You can try to decode it as base64 and see if the results make any sense, no more.
The base64 string simply consists of ASCII characters, 8-bit padded, '0'..'9', 'A'..'Z', 'a'...'z', '+', '/'. There are several variants of the encoding. Usually, MIME specification (based on RFC 1421) is implied. See:
http://en.wikipedia.org/wiki/Base64[
^],
http://en.wikipedia.org/wiki/Base64#MIME[
^],
http://tools.ietf.org/html/rfc1421[
^].
Imagine you generated a completely random sequence of such characters and format text exactly as base64 encoders usually do, using same delimiters, including end-of-line characters — this formatting is purely optional for base64. Is it a base64-encoded data? Yes and no — it depends on how you look at it. What is "
simple string" anyway? There is no such thing. (By the way, I don't understand how division by 4 can be relevant here.)
The problem is: the standard for base64 encoding does not include any
meta-data which would help to recognize the format. Such meta-data is always placed outside of base64 data. For example, in e-mail you will usually get a header
Content-Type: multipart/mixed
; and one or more of the parts will have part headers with
Content-Type: application/octet-stream
and
Content-Transfer-Encoding: base64
. You can consider this as the meta-data showing you how to use the string. You should do something like that if you use base64 in your software, but what to do with available legacy data? Too late…
—SA