iOS Question iEncryption library

Giuliano Cucchiarini

Member
Licensed User
Longtime User
Hi
I am trying to encrypt and decrypt a string using the iEncryption library (ver 1.01).
(I need a very simple method)

Dim PlainText as string="String to encrypt"
Dim myCipher As Cipher
Dim myArray() As Byte=PlainText.GetBytes("UTF8")
Dim encriptedPassword() As Byte=myCipher.Encrypt(myArray ,"myPassword")


This very simple code does not work, the programs get stuck in the last instruction, without any error message.

Can you help me
Thank you

Giuliano C.
 
Last edited:

Giuliano Cucchiarini

Member
Licensed User
Longtime User
Hi Erel, what I created a brand new project, with only the 4 instructions I sent you...
Same story, but I noticed that if I build a release App, it works...
Maybe is a bug somewhere....
 
Upvote 0

Giuliano Cucchiarini

Member
Licensed User
Longtime User
Sorry Erel for the last comment, I understand that the encryption must give a different result every time, by design...
Are you going to fix the 64 bit issue?
Thank very much for your precious help!
Giuliano C.
 
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User
Erel , I tried to do the same and the application freezes on iphone 4S on the line :

myEncript = myCipher.Encrypt ( myArray , " fakhfaodfhdf344230oaljfalh " )

It is a bug with this library or my code ?

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private Button1 As Button
    Private myEncript() As Byte
    Private StringEncriptada As String
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Pagetest")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    Dim PlainText As String="esteeumtestedeencriptacao"
    Dim myCipher As Cipher
    Dim bc As ByteConverter
    Dim myArray() As Byte=bc.StringToBytes(PlainText,"ISO-8859-1")
    myEncript = myCipher.Encrypt(myArray ,"fakhfaodfhdf344230oaljfalh")
    Dim bc As ByteConverter
    StringEncriptada=bc.StringFromBytes(myEncript,"ISO-8859-1")
End Sub
 
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User
Excellent Erel, Thanks !!! Now is working after upgrading iEncryption v1.02. I 'm using the hosted mac. My before library is 1.01.

Here is my code for encryption and decryption. I accept suggestions for improvement :)


B4X:
'Code module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private Button1 As Button
    Private myEncript() As Byte
    Private StringEncriptada As String
    Private Password As String = "fakhfaodfhdf344230oaljfalh"  '<= Encryption password
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Pagetest")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
  
    'Encrypt
    Dim PlainText As String="This is a encryption test..."   '<== String to encryption
    Dim myCipher As Cipher
    Dim bc As ByteConverter
    Dim myArray() As Byte=bc.StringToBytes(PlainText,"ISO-8859-1")
    myEncript = myCipher.Encrypt(myArray ,Password)
    Dim bc As ByteConverter
    StringEncriptada=bc.StringFromBytes(myEncript,"ISO-8859-1")
End Sub

Sub Button1_Click
    'Decrypt
    Dim myCipher As Cipher
    Dim PlainText1 As String
    Dim Bc As ByteConverter
    Dim myArray() As Byte=Bc.StringToBytes(StringEncriptada,"ISO-8859-1")
    PlainText1 = Bc.StringFromBytes(myCipher.Decrypt(myArray, Password), "ISO-8859-1")
    Log("Decripted=" & PlainText1)
End Sub
 
Last edited:
Upvote 0
Top