RSAEncyptor for iOS

Hi,

I am trying to add some simple encryption to a TextArea, so that the information can be sent via email from an iPad without the sender being able to see the message, but the receiver will be able to easily decrypt the message once received using another app.

I am using the Xojo RSAEncryptor and the RSADecryptor. What I am having problems with is the Encryption in iOS. The encryption code is modified from the desktop version as shown below.

[code] Dim publicKey As Xojo.Core.MemoryBlock = DecodeBase64(PublicKeyArea.Text)

Dim msg As MemoryBlock
msg = OriginalTextArea.Text

// Encrypt msg using the publicKey
Dim encryptedData As MemoryBlock = Crypto.RSAEncrypt( msg, publicKey )

If encryptedData <> Nil Then
EncryptedTextArea.Text = EncodeBase64(encryptedData)
End If[/code]

I get an error the DecodeBase64 and EncodeBas64 don’t exist. I was wondering if there was a easy way to get around this in Xojo iOS?

iOS does not have these commands.

Encode/DecodeBase64 is available in https://github.com/Mitchboo/XojoiOSWrapper

Hi Michel,

Thanks for taking the time to help. I did see the iOSWrapper. I just don’t see how to implement it with the RSAEncyrptor. Do I just drag the wrapper into the project? I don’t understand how it works.

[quote=272853:@James Redway]Hi Michel,

Thanks for taking the time to help. I did see the iOSWrapper. I just don’t see how to implement it with the RSAEncyrptor. Do I just drag the wrapper into the project? I don’t understand how it works.[/quote]

Drag the wrapper into the project, and it will give you access to all the methods listed, including EncodeBase64 and DecodeBase64.

I tried doing that. My code is:

[code] Dim publicKey As Text = DecodeBase64(PublicKeyArea.Text)

Dim msg As MemoryBlock
msg = OriginalTextArea.Text

// Encrypt msg using the publicKey
Dim encryptedData As MemoryBlock = Crypto.RSAEncrypt( msg, publicKey )

If encryptedData <> Nil Then
EncryptedTextArea.Text = EncodeBase64(encryptedData)
End If[/code]

I get 3 errors.

  1. Type mismatch error. Expected class xojoCore.MemoryBlock, but got Text on the line:
    Dim publicKey As Text = DecodeBase64(PublicKeyArea.Text)

  2. Type mismatch error. Expected class xojoCoreMemoryBlock, but got Text on line:
    msg = OriginalTextArea.Text

  3. This method extends type Text, but the base expression is class View1.View1 on line:
    EncryptedTextArea.Text = EncodeBase64(encryptedData)