iOS Question Using B4XAES Lib

Swissmade

Well-Known Member
Licensed User
Longtime User

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm not familiar with this library implementation but you can use (j)B4XEncryption, iEncryption. I think that the library you mentioned actually wraps these libraries.

 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
I'm not familiar with this library implementation but you can use (j)B4XEncryption, iEncryption. I think that the library you mentioned actually wraps these libraries.

This I have try and the message from the Compiler I get are many errors.
But maybe B4XCipher has to go as Cipher and without B4XAES Library then the errors are gone.

Will test this and let you know the result.

Thanks for helping.
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
True. The code with (j)B4XEncryption and iEncryption will not be 100% identical, only 95% but the encryption is cross platform.
Simply use conditional compilation.
Ok will test.|

Thanks Erel
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
95% but the encryption is cross platform
I think I do something wrong or Apple Cipher is not really the same as B4Cipher.
It is not working Encrypt QR build with B4J can not be read by B4i.
In B4J and B4A I use jB4XEncryption and for B4i I use IEncryption
B4J, B4A Encrypt and Decrypt:
Public Sub SetAES1(Mess As String, Key As String, HaveToEncrypt As Boolean) As String
    Dim AesString As String
    Dim c As B4XCipher
    Dim b() As Byte
    Dim su As StringUtils
    Try
        If HaveToEncrypt = True Then
            b = c.Encrypt(Mess.GetBytes("utf8"), Key)
            AesString = su.EncodeBase64(b)
            Log(AesString)
        Else
            Dim enc() As Byte = su.DecodeBase64(Mess)
            b = c.Decrypt(enc, Key)
            AesString = BytesToString(b, 0, b.Length, "utf8")
        End If
    Catch
'        ShowLog("Error getting Password or Key", True, LastException.Message)
        AesString = "Wrong-Key"
    End Try
    Return AesString
End Sub

B4i Encrypt and Decrypt:
Public Sub SetAES1(Mess As String, Key As String, HaveToEncrypt As Boolean) As String
    Dim AesString As String
    Dim c As Cipher
    Dim b() As Byte
    Dim su As StringUtils
    Try
        If HaveToEncrypt = True Then
            b = c.Encrypt(Mess.GetBytes("utf8"), Key)
            AesString = su.EncodeBase64(b)
            Log(AesString)
        Else
            Dim enc() As Byte = su.DecodeBase64(Mess)
            b = c.Decrypt(enc, Key)
            AesString = BytesToString(b, 0, b.Length, "utf8")  <Crash here wrong Key
        End If
    Catch
'        ShowLog("Error getting Password or Key", True, LastException.Message)
        AesString = "Wrong-Key"
    End Try

    Return AesString
End Sub
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
1663661563204.png

QR Code to test
Text = This is a Encrypted QR Code
key = test Key
 

Attachments

  • Barcode Reader.zip
    180 KB · Views: 173
Last edited:
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
Add B4XEncryption
Test that but now the error File Not Found

B4iProject/b4i_main.m:2:
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.h:5:9: fatal error: 'B4XEncryption.h' file not found
#import "B4XEncryption.h"
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
You don't need to add anything.
Download the example project. Change the package name based on your provision profile and run it.
Then I think the problem is, that I don't use B4XPages
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
I'm sorry but I cannot further help you here.
The example project runs as-is. You don't need to change anything. And the feature has nothing to do with B4XPages.
Ok will test it
Thanks Erel
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
Hm I wondering.
All is working when I use the code generated with encrypt.
Put when I Scan the code as QR and read it back to Decrypt I get a other code.

Funny this . Is it possible that the scanner already do some Encryption?
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
Thanks Erel,
You have give me the direction to go and let me think.
I forgot in the scan part to remark the line
Forgot to remark Line:
sb.Append("Detected code:").Append(CRLF)
This line is add to the scan result and I have not seen it in the first place.

Problem solved
Thanks again to let me search more.
 
Upvote 0
Top