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:
B4i Version: 5.00
Parsing code. (0.00s)
Compiling code. (0.13s)
Compiling layouts code. (0.00s)
Compiling debugger engine code. (0.87s)
Building Xcode project (0.18s)
Sending data to remote compiler. Error
Out: Build settings from command line:
ARCHS = arm64
CODE_SIGN_IDENTITY = iPhone Distribution: xxxxxx (RRJA7L88ZG)
CONFIGURATION_BUILD_DIR = /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/Payload
OTHER_CODE_SIGN_FLAGS = --keychain <user id>
PRODUCT_NAME = B4i Example
PROVISIONING_PROFILE = 99d52011-a3ea-475c-ada2-1bd692c5e7bf

=== BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap
write-file /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example.hmap
write-file /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap
write-file /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-non-framework-target-headers.hmap
/bin/mkdir -p /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64
write-file /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/B4i\ Example.LinkFileList
write-file /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap
write-file /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap

Create product structure
/bin/mkdir -p /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/Payload/B4i\ Example.app

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.o B4iProject/main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch arm64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/1p/kw_s6xl11411w_xq3q0sltl00000gp/C/org.llvm.clang/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DB4I_VERSION=9 -DNS_BLOCK_ASSERTIONS=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -miphoneos-version-min=7.0 -fvisibility=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -iquote /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/Payload/include -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/arm64 -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.d --serialize-diagnostics /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.dia -c /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/B4iProject/main.m -o /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.o

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o B4iProject/b4i_main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch arm64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/1p/kw_s6xl11411w_xq3q0sltl00000gp/C/org.llvm.clang/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DB4I_VERSION=9 -DNS_BLOCK_ASSERTIONS=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -miphoneos-version-min=7.0 -fvisibility=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -iquote /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/Payload/include -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/arm64 -I/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.d --serialize-diagnostics /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.dia -c /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/B4iProject/b4i_main.m -o /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o
In file included from /Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/B4iProject/b4i_main.m:2:
/Users/AaronMacPro/Desktop/macserver/UploadedProjects/<user id>/B4iProject/b4i_main.h:2:9: fatal error: 'B4XEncryption.h' file not found
#import "B4XEncryption.h"
^~~~~~~~~~~~~~~~~
1 error generated.


Error: ** BUILD FAILED **


The following build commands failed:
CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o B4iProject/b4i_main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

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:
h files

iFirebaseNotifications: 1.00
iCustomDialog: 1.00
iAdMob: 1.50
iXmlBuilder: 1.00
iEventKit: 1.00
iReleaseLogger: 1.00
iSideMenu: 1.01
iSVG: 1.20
iActivityBar: 1.01
iTableView: 1.21
iUI8: 1.50
iStringUtils: 1.01
iSQL: 1.50
iArchiver: 1.20
iXUI: 1.70
xCustomListView
iGameView: 1.0
iSpeechRecognition: 1.00
iHUD: 1.00
iNFC
iLeadbolt: 2.00
iRandomAccessFile: 1.72
iGameCenter: 1.01
iHttp: 1.01
iStore: 1.21
iNet: 1.70
iGoogleMaps: 1.40
iCore: 5.00
iFacebook: 1.00
iBLE: 2.00
iBarcode: 1.20
iWebSocket: 1.10
iCallSubUtils
iXmlSax: 1.10
iDebug2: 1.60
iFirebaseAuth: 1.02
iMedia: 1.22
iFirebaseAnalytics: 1.00
iDesigner: 1.20
iDateUtils
iFirebaseStorage: 1.10
iTabStrip: 1.00
iCustomListView
iRSA: 1.0
iAd: 1.00
iEncryption: 1.02
iContacts: 1.00
iDebug: 1.60
iNetwork: 1.32
iPhone: 2.00
iLocation: 1.20
iCircularProgress: 1.00
iBitmapCreator
iMQTT: 1.0
iAnalytics: 1.0
iUI9: 1.0
iJSON: 1.0
iDropboxSync: 1.00
iHttpUtils2
a files

libiBLE, size=228216, modified=08/17/2017 04:02:22
libiDropboxSync, size=80960, modified=05/04/2017 01:19:36
libiHttpUtils2, size=365704, modified=01/17/2018 03:23:54
libiHttp, size=122656, modified=08/17/2017 04:03:04
libiWebSocket, size=401984, modified=01/15/2018 04:53:58
libiCustomDialog, size=2720512, modified=08/17/2017 04:02:32
libiNetwork, size=267336, modified=11/19/2017 02:13:02
libxCustomListView, size=423616, modified=05/07/2018 04:55:58
libiLocation, size=125184, modified=08/17/2017 04:03:14
libiStore, size=75856, modified=05/15/2018 02:23:18
libiNFC, size=40424, modified=10/08/2017 06:48:28
libiHUD, size=291472, modified=08/17/2017 04:03:06
libiRandomAccessFile, size=399912, modified=08/17/2017 04:03:38
libiNet, size=550208, modified=10/09/2017 05:33:34
libiBitmapCreator, size=377272, modified=05/17/2018 01:34:02
libiSpeechRecognition, size=168816, modified=08/17/2017 04:03:50
libiDebug2, size=1123216, modified=05/10/2018 06:05:30
libiXmlSax, size=62976, modified=08/17/2017 04:04:12
libiSQL, size=408088, modified=08/17/2017 04:03:54
libiEncryption, size=66512, modified=08/17/2017 04:02:34
libiUI8, size=569896, modified=11/28/2017 08:05:34
libiXUI, size=688856, modified=05/14/2018 06:43:40
libiContacts, size=142816, modified=08/17/2017 04:02:24
libiTableView, size=194152, modified=05/04/2017 01:19:36
libiDesigner, size=939304, modified=08/17/2017 04:57:22
libiCallSubUtils, size=126952, modified=08/17/2017 04:33:06
libCore, size=3859344, modified=05/13/2018 05:18:50
libiSVG, size=83312, modified=08/17/2017 04:56:48
libiTabStrip, size=1335904, modified=08/17/2017 04:56:58
libiAdMob, size=97288, modified=08/17/2017 04:02:14
libiCustomListView, size=316424, modified=08/27/2017 07:51:10
libiMQTT, size=1703608, modified=08/17/2017 04:03:24
libiFacebook, size=93392, modified=08/17/2017 04:02:40
libiUI9, size=107056, modified=08/17/2017 04:04:04
libiAd, size=39072, modified=08/17/2017 04:02:12
libiFirebaseAuth, size=161512, modified=08/17/2017 04:02:44
libiGoogleMaps, size=170512, modified=12/07/2017 23:59:56
libAdapterInMobi, size=1125360, modified=05/04/2017 01:19:34
libiAnalytics, size=39392, modified=08/17/2017 04:02:16
libiLeadbolt, size=21440, modified=05/04/2017 01:19:36
libiGameCenter, size=158080, modified=11/05/2017 21:50:46
libiCircularProgress, size=259400, modified=08/03/2015 06:54:04
libiFirebaseStorage, size=140832, modified=12/06/2017 00:57:10
libiJSON, size=52960, modified=08/17/2017 04:03:10
libiStringUtils, size=55272, modified=04/11/2018 02:22:50
libiBarcode, size=249056, modified=08/17/2017 04:02:20
libiPhone, size=326664, modified=08/17/2017 04:03:34
libiRSA, size=145648, modified=09/03/2017 01:01:38
libiActivityBar, size=538144, modified=10/01/2015 07:25:10
libiGameView, size=4089072, modified=08/17/2017 04:03:00
libiFirebaseNotifications, size=66600, modified=08/17/2017 04:02:46
libiArchiver, size=463088, modified=08/17/2017 04:02:18
libiDateUtils, size=257440, modified=10/18/2017 02:21:58
libiXmlBuilder, size=151384, modified=08/17/2017 04:04:08
libiSideMenu, size=505920, modified=08/17/2017 04:03:44
libiMedia, size=259208, modified=10/24/2017 21:40:54
libiReleaseLogger, size=50136, modified=08/17/2017 03:03:40
libiEventKit, size=330256, modified=08/17/2017 04:56:26
libiFirebaseAnalytics, size=33880, modified=08/17/2017 04:02:42
 
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:
output.png

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
Top