Reputation: 26488
I need a way to know if a string is Base64 encoded... any idea ?
thanks
Upvotes: 1
Views: 2881
Reputation: 20124
The string length hast to be a multiple of 4 and only the following characters are allowed A-Z, a-z, 0-9 *+, */ and = as padding character (only at the end)
Upvotes: 4
Reputation: 6432
IMHO you need to try to decode it, and if it fails - it is not encoded.
There are many Base64 decoders for Java, here are some:
sun.misc.BASE64Decoder
http://migbase64.sourceforge.net/
http://www.source-code.biz/base64coder/java/
Upvotes: 4