Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
7
Erster Beitrag:
vor 11 Monaten, 3 Wochen
Letzter Beitrag:
vor 11 Monaten, 3 Wochen
Beteiligte Autoren:
steve erts, Fabrice Harari, Paulo Oliveira, Alexandre Leclerc

Decode Base64 Encoded Emails

Startbeitrag von steve erts am 30.08.2016 15:43

Hi,

I'm trying to read in some emails into my database and some messages are coming in encoded as Base64. I know why this is happening but I'm wondering if anyone knows how to decode the message body in Windev?

Thanks

steve

Antworten:

did you try with the Uncrypt function?

http://doc.windev.com/en-US/?3024035

von Paulo Oliveira - am 30.08.2016 16:41
Quote
Paulo Oliveira
did you try with the Uncrypt function?

http://doc.windev.com/en-US/?3024035


You know, I didn't even think about that as I assumed that required some sort of password. (I use encryption in several places in my app) but it appears that you are right.

Decrypting a stream in base64binary format
To decrypt a string encrypted in base64, you must use:
ResultString = Uncrypt(EncryptedString, "", cryptNone)

Thanks!

von steve erts - am 30.08.2016 16:46
Hi Steve,

Have you tried to simply use the email variable?

e is email
e.Source = [base 64 email]

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 30.08.2016 16:58
Quote
Alexandre Leclerc
Hi Steve,

Have you tried to simply use the email variable?

e is email
e.Source = [base 64 email]

Best regards,
Alexandre Leclerc


Hi Alexander,

I'm not following. I'm not trying to encode the email message. I'm trying to decode it it into a readable string.

Email..source is encrypted when I read it.

What am I missing?

steve

von steve erts - am 30.08.2016 17:49
Hi steve,

what Alexandre means is that if you put the whole email into email..source, then you have access to all the email members, including the array of attachments (and the whole base 64 business is all about attachments)

Best regards

von Fabrice Harari - am 30.08.2016 18:03
Unfortunately, the issue was caused by complex signatures in user emails so the body of message (as far as I can tell) is getting encoded. I ended up writing a procedure to decrypt the message. Here it in case it is helpful to anyone.



PROCEDURE GP_DecryptBase64(sEmailstring is string)

sEncryptedPart is string
sDecryptedPart is string
sHeader is string
sRebuiltMessage is string


nBase64Start is int=Position(sEmailstring,"base64",0,FromBeginning)

IF nBase64Start=0 THEN

RESULT sEmailstring


ELSE

sHeader=Left(sEmailstring,nBase64Start)
nBase64End is int=Length(sEmailstring)
sEncryptedPart=Middle(sEmailstring,nBase64Start+6,nBase64End-nBase64Start+6)

sDecryptedPart=Uncrypt(sEncryptedPart,"",cryptNone)

sRebuiltMessage=sHeader+sDecryptedPart

RESULT sRebuiltMessage

END

von steve erts - am 30.08.2016 18:55
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.