iOS Question Error with B4XEncryption

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I can't work out if I am doing the following correct or not as I am getting error while trying to compile the app.

I have added the librarys:
B4XEncryption (version 1.00)
iStringUtils (Version 1.01)

I have added the code:

B4X:
Public Sub EncryptText(text As String) As String
    Dim c As B4XCipher
    Return su.EncodeBase64(c.Encrypt(text.GetBytes("utf8"), "123456789"))
End Sub

Public Sub DecryptText(EncryptedData As String) As String
    Dim c As B4XCipher
    Dim b() As Byte = c.Decrypt(su.DecodeBase64(EncryptedData), "123456789")
    Return BytesToString(b, 0, b.Length, "utf8")
End Sub

And in Application_Start I have added:

B4X:
Log(EncryptText("hello"))

When I compile the app I get the following error:

I am using B4i Version 5.00 (using Windows 10 in VM)
Local Build Server 5.02
xCode 9.4

Am I doing the above code correct, or have I done it wrong ?
 

aaronk

Well-Known Member
Licensed User
Longtime User
If it's not a silly question, which files do I need to copy over?

I can't seem to find that file (B4XEncryption.h) anywhere.

Here is what I currently have on my Mac:
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Where have you downloaded it from?
https://www.b4x.com/android/forum/threads/b4xencryption.48177/#content
I guess the above is only for B4A and not B4i.

I have now used iEncryption lib (thought that B4XEncryption was able to be used with B4i)

When I use:
B4X:
Public Sub EncryptText(text As String) As String
    Dim c As Cipher
    Return su.EncodeBase64(c.Encrypt(text.GetBytes("utf8"), "123456789"))
End Sub

Public Sub DecryptText(EncryptedData As String) As String
    Dim c As Cipher
    Dim b() As Byte = c.Decrypt(su.DecodeBase64(EncryptedData), "123456789")
    Return BytesToString(b, 0, b.Length, "utf8")
End Sub

And then log the output:
B4X:
Log(EncryptText("hello"))
    Log(DecryptText(EncryptText("hello")))

It seems to log:

Notice the decrypted text has those squares at the end of the 'hello' text.

Have I done something wrong when decrypting the text ?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…