Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Dec 10, 2019 10:29 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 10:08 am 
Offline

Joined: Wed Jan 31, 2007 9:01 am
Posts: 273
Location: Saratoga Springs, NY area
Hi,

I am trying to learn how to add SMTP/POP-mail message body encryption/decryption by adding an ActiveX (1Crypt: http://www.atma-software.com)
into the project. I have "rusty" novice skills, so getting the text encrypted/decrypted by the ActiveX control is a steep climb.

To start out, I am using the basic email sample that is included in the RB installation program files>Examples, and so far have added the ActiveX to the project. When I look at the newly added ActiveX, it has a number of items already specified: especially a number of its methods and properties. Clicking on any of these and the code is all there, no errors in evidence.

So, my learning challenge initially is to take, for example, the SMTP send mail window (send demo Window in the RB sample file) and add the ActiveX's encrypt string function, get it working so that a message body's text is encrypted before sending. Then if I test, receiving the email sent in the sample's "demo Window," the message's body text should now be encrypted (the ActiveX will encrypt it into a long string of numbers and letters). Later, if the encrypt string works OK, then adding the decrypt string to the receiving "demo Window" should decrypt the message body's encrypted text and display it a clear readable text.

For my skill level, this is challenging. I've been extensively reading the ActiveX's help materials, plus the language reference, and checking in this forum and online for clues as to how to get this to work. The ActiveX language is modeled on Visual Basic so I can at least follow it. For example, the help guide says:

Encryption is simple
e.g. To encrypt a string in Visual Basic .NET :
MyEncryptedString = AxOneCrypt.EncryptString(MyKey, MyString)

However, I'm not sure what I need to do to start. Any help, suggestions would be greatly appreciated.

More ActiveX Help Guide examples:

EncryptString

--------------------------------------------------------------------------------

Encrypts a string using a key.


The encrypted string is returned by the method. It will be either hex or binary, depending on the value of HexEncryptStrings.

The Key is case-sensitive.

Parameters

Name Data Type Description
Key string Encryption Key / Password / Phrase
InString string Input string (plaintext)

Return Value

Data Type Description
string Encrypted string
--------------------------------------------------------------------------------
DecryptString

--------------------------------------------------------------------------------

Decrypts a string previously encrypted with EncryptString.

For the string to be decrypted correctly the Key must be the same, and HexEncryptStrings must also have the same value.

The Key is case-sensitive.

Parameters

Name Data Type Description
Key string Encryption Key / Password / Phrase
InString string Input string (encrypted)

Return Value

Data Type Description
string Plaintext string

_________________
writer

Windows 7 Home Premium 64 bit, Core i7, 8G RAM, ATI Radeon HD5770, Release 2011r3


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 7:24 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
Writer,

Not a answer direct to your question, but take a look at EncodeBase64 and DecodeBase64.

For example you send the mail:
EmailMessage.BodyPlainText = EncodeBase64("Hello")

And when you receive the mail in MessageReceived event:
msgbox(DecodeBase64(email.BodyPlainText))


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 7:47 pm 
Offline

Joined: Wed Jan 31, 2007 9:01 am
Posts: 273
Location: Saratoga Springs, NY area
Hi serd83,

Nice to hear from you. How are you?

I wish I could use base 64. I am a social worker in the USA. Any health data (data about a person's health, illness, diseases, etc.) transmitted electronically by email, internet is required by USA law (HIPAA: http://hipaa-encryption.com/HIPAA-Compliance/phi-encryption/government-encryption-standard-advanced-encryption-standard-aes/) to be kept private/confidential and use specific encryption standards: symmetric > 112 bits (but generally this is accomplished by using AES 128 or AES 256). So, the SMTP/PoP3 email program that I am trying to build (for use between me and a few people that I would provide counseling help), needs to have the message body encrypted to meet this requirement.

I have an excellent encryption/decryption ActiveX (AES 256), but it is a big challenge to figure out how to call its functions for encrypt string and decrypt string, how to integrate this into the SMTP/PoP3 .rbt sample file. See download links for the ActiveX in my above posting. SMTP/PoP3 email is in the sample files that come with RB.

I have been trying for 2 days. All I can do, so far, is add the ActiveX control to the sample's rbt. But, how to get it to encrypt an SMTP message text (string) before sending, and to decrypt a PoP3 message text that is received and selected for decryption/viewing, is beyond my skills.

Please take a look at the sample files and even the ActiveX trial version. I would appreciate any help getting this to work.

Kind Regards,

_________________
writer

Windows 7 Home Premium 64 bit, Core i7, 8G RAM, ATI Radeon HD5770, Release 2011r3


Last edited by writer on Sat May 29, 2010 10:31 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 7:48 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
To your orginal question, you will use it in RB like this:
dim s as string
dim key as string = "1234" // just for test
s = OneCryptA1.EncryptString(key, "Hello")

EmailMessage.BodyPlainText = s

When you read the mail:
dim s as string
dim key as string = "1234" // just for test
s = OneCryptA1.DecryptString(key, email.BodyPlainText)

msgbox(s)


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 7:53 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
Hi Writer,

I am fine, hope you are too. Long time not hear from you here in the forum. :)

I have look to the AcitveX control and can explain it more in detail if you can't bring it to work which I wrote above.


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 8:01 pm 
Offline

Joined: Wed Jan 31, 2007 9:01 am
Posts: 273
Location: Saratoga Springs, NY area
Hi serd83,

Our postings must have crossed in cyberspace.

Thank you for you suggestions.

I tried putting your first (send) code into the send button (send email window) but this caused an error: this method or property does not exist for "EmailMessage.BodyPlainText = s"

I haven't been using RB for about 6 months, so I'm re-learning. I am not sure where to put the code you suggested for the test.

I would appreciate additional help getting OneCrypt ( http://www.atma-software.com/1crypt/index.html) working in the PoP3 and SMTP mail examples.

Kind Regards,

_________________
writer

Windows 7 Home Premium 64 bit, Core i7, 8G RAM, ATI Radeon HD5770, Release 2011r3


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 10:04 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
OK, I try it now and all works.

Since there are already two e-mail examples in one file we will use it for our test.
1. Open the project "Email Example" from the examples folder
2. In the IDE add the ActiveX control OneCryptA
3. In "sendDemoWindow" add this method(select the code below and paste it to sendDemoWindow)
Function Encrypt(key as string, s as string) As String
dim e as string = self.OneCryptA1.EncryptString(key, s)
return e
End Function

4. In "sendDemoWindow" window add a TextField and rename it to KeyField
5. In "sendDemoWindow" window add the control OneCryptA, the name is automatic OneCryptA1
6. In "sendDemoWindow" window, in PushButton1.Action event change the line from
mail.bodyPlainText = bodyFld.text

to
mail.bodyPlainText = Encrypt(keyfield, bodyFld.text)

7. In "demoWindow" window add this method(select the code below and paste it to demoWindow)
Function Decrypt(key as string, s as string) As String
dim d as string = self.OneCryptA1.DecryptString(key, s)
return d
End Function

8. In "demoWindow" window add the control OneCryptA, the name is automatic OneCryptA1
9. In "demoWindow" window add a TextField and rename it to KeyField
10. In "demoWindow" window, in Socket1.MessageReceived event remove all code first and then put only this line
bodyFld.text = Decrypt(keyfield.text, email.BodyPlainText)

Before you send a mail, you must write a key to the keyfield. When you read the mail you must write the same key to the keyfield what you write for sending the mail. In other words, the key must be identical.

Only you and the recipient which know the key can read the mail correct, otherwise it will display it not as orginal.


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 10:51 pm 
Offline

Joined: Wed Jan 31, 2007 9:01 am
Posts: 273
Location: Saratoga Springs, NY area
Hi serd83,

I added this code and made the changes: when I run the project, I am getting an error message in the send demo window:

Parameters are not compatible with this function:
mail.bodyPlainText = Encrypt(keyfield, bodyFld.text)

Not sure why. I double checked (started over and did each step again) and made sure I followed instructions exactly.

I keep getting the same error message.

_________________
writer

Windows 7 Home Premium 64 bit, Core i7, 8G RAM, ATI Radeon HD5770, Release 2011r3


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sat May 29, 2010 11:08 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
It should
mail.bodyPlainText = Encrypt(keyfield.text, bodyFld.text)


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sun May 30, 2010 6:40 am 
Offline

Joined: Wed Jan 31, 2007 9:01 am
Posts: 273
Location: Saratoga Springs, NY area
Hi serd83,

Replacing the code , now there is no error message.

But when I try to send an encrypted email (click the send button), the debug program fails: it crashes and closes.

If I comment out (//) the code line

mail.bodyPlainText = Encrypt(keyfield.text, bodyFld.text)


the crashing stops.

So, unfortunately, something in the send email window (probably in the encryption function) is still not working correctly. :(

Here is the crash report:

Quote:
Source
DebugMy Application.exe

Summary
Stopped working

Date
‎5/‎30/‎2010 7:31 AM

Status
Report sent

Description
Faulting Application Path: C:\Users\Stephen\Desktop\RBmail\DebugMy Application\DebugMy Application.exe

Problem signature
Problem Event Name: APPCRASH
Application Name: DebugMy Application.exe
Application Version: 1.0.0.0
Application Timestamp: 4bd89424
Fault Module Name: StackHash_0a9e
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c0000005
Exception Offset: 00000001
OS Version: 6.1.7600.2.0.0.768.3
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

Extra information about the problem
Bucket ID: 1887871810

_________________
writer

Windows 7 Home Premium 64 bit, Core i7, 8G RAM, ATI Radeon HD5770, Release 2011r3


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sun May 30, 2010 11:07 am 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
Could you upload the file?

I use RB2007 R3 and it works. What version do you use?


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sun May 30, 2010 11:14 am 
Offline

Joined: Wed Jan 31, 2007 9:01 am
Posts: 273
Location: Saratoga Springs, NY area
Hi serd83,

I am using 2010 release 2.

I keep getting crashes when I click the send button.

_________________
writer

Windows 7 Home Premium 64 bit, Core i7, 8G RAM, ATI Radeon HD5770, Release 2011r3


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sun May 30, 2010 11:15 am 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
Is there a error message?


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sun May 30, 2010 11:24 am 
Offline

Joined: Wed Jan 31, 2007 9:01 am
Posts: 273
Location: Saratoga Springs, NY area
Hi serd83,

No error message. (I am using "run" to preview/debug.) The demo window seems OK. Only the send demo window causes a crash, and only when I click the send button. If I comment out that one line of code for the encrypt function, no crash.

_________________
writer

Windows 7 Home Premium 64 bit, Core i7, 8G RAM, ATI Radeon HD5770, Release 2011r3


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding ActiveX to encrypt/decrypt SMTP/POP Mail
PostPosted: Sun May 30, 2010 11:34 am 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
I can't say what is wrong until I see not the code. Could you upload the file?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group