Skip to content

Instantly share code, notes, and snippets.

@kasimok
Created December 14, 2016 02:27
Show Gist options
  • Save kasimok/66343a9d1b964209cd552d2222a98b0f to your computer and use it in GitHub Desktop.
Save kasimok/66343a9d1b964209cd552d2222a98b0f to your computer and use it in GitHub Desktop.
Method to verify if a string is legal base64 encoded
/**
* Check if valid BASE64 String.
* @param value
* @return
*/
public static boolean checkIfValidBase64(String value){
return value.matches("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment