Android : Android Base64 String Detection

on Thursday, September 4, 2014


What I'm trying to achieve is detection of base64 string... I've tried following approaches, but didn't worked for all strings.


APPROACH:



Searched for android.util.Base64 package, but it is also not providing any of the function to detect base64 string...!!!



APPROACH:



Used regex which is highly upvoted on Stackoverflow but not worked!!


^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$


It accepts "Clip" string as base64 even if it's not...



APPROACH:



(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})


Even this has same issue....!!



APPROACH:



Used latest commons-codec library (version 1.9).. but, there is no method defination in it of isBase64(String str) method (which was highly recommended by many peaople on google search)..!!


To resolve this, I searched a lot but no working answer was found...!!



Can anybody help me to resolve this issue and get me working solution for all set of strings?


0 comments:

Post a Comment