1

I have raw encoded base64 emails that I would like to decode. However on the raw email data, there is 3 sections to it.

The first section is HEADERS. The second section is HTML content / tags. The third section is the encoded base64.

I can manually add the string to my program and decode it just fine. However, I want to TARGET or PULL the encoded message into my program, so when I run it, its automatic.

But how do I target the encryption data when the header and html content / tags are in the way? I can read files through PHP, but would I do something like

if (strlength IS REALLY LONG == encoded data) 
{decode that data}
Shawn
  • 1,175
  • 2
  • 11
  • 20
  • This may be relevant to your question: http://stackoverflow.com/questions/8571501/how-to-check-whether-the-string-is-base64-encoded-or-not – Kaylined Feb 04 '17 at 19:52

1 Answers1

0

Based on the following link, your solution would be something like this:

How to check whether the string is base64 encoded or not

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

if(preg_match($regex,$string) != false){
   //some operation
   $decoded = base64_decode($string);
}
Community
  • 1
  • 1
Kaylined
  • 655
  • 6
  • 15