Easiest way to detect if a string is base64 encoded or not?

Hi there, has anyone a good way to detect if a string is base64 encoded or not? I need to submit a file to an API as a base64 encoded string. My workflow receives input files which are sometimes base64 encoded and sometimes plain text. I need to detect the input files which are not base64 encoded and encode them before sending them to the API.

You should be able to use a pattern match step with RegEx followed by a decision step that has a path for each encoded / not encoded

Identify Base64 Encoding RegEx ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$

1 Like

Thanks man. Seems to work.

1 Like

I use regex as mentioned, then send it to GPT API via pyrhon plugin for decoding and analysis of what it does then get the response in email. I’ve been considering parsing out any URL from decoded text and sending it to reputation check because encoded commands more often than not are hiding some kind of external link in powershell or other script.