Page 1 of 1
Transferring an Array from desktop to mobile
Posted: Wed Feb 03, 2021 4:34 pm
by glenn9
Dear All,
I've created on desktop a basic two card 'dictionary' type of app with a scrolling list of of 'terms' on Card A which when clicked leads to an information field corresponding to that term on Card B.
On the desktop the two cards are populated from an array which successfully saves and loads using the encode and decode commands to specialfolderpath ("documents").
I now would like to run the app on mobile (android) and although the app transfers to mobile nicely, the Array data is missing and here lies my problem as I'm not understanding how to transfer the 'array' that is saved on the desktop to the mobile device.
So far I thought I might save the array as a custom property within the app using the code from the BYU Array example
Code: Select all
on closeStack
set the dictionaryArray of this stack to gDictArray
end closeStack
but I'm not sure how to save the 'gDictArray' to the mobile specialfolderpath("documents") so that it can then be loaded up by the mobile app.
Hope this makes sense!
Grateful for any advice.
Many thanks,
Glenn
Re: Transferring an Array from desktop to mobile
Posted: Wed Feb 03, 2021 5:04 pm
by Thierry
Hi Glenn,
From the dicionary:
Description
Use the arrayDecode function to rebuild an array from an encoded string produced by the arrayEncode function.
Encoding and decoding arrays is designed to allow arrays to be written to a file on disk, or sent across a network. See the arrayEncode reference for more information on doing this.
HTH,
Thierry
Re: Transferring an Array from desktop to mobile
Posted: Wed Feb 03, 2021 5:21 pm
by glenn9
Thanks Thierry, I'll study this as it seems as though this will give me the answer. Regards, Glenn
Re: Transferring an Array from desktop to mobile
Posted: Thu Feb 04, 2021 8:32 am
by mrcoollion
Here are my routines (code snippets) for saving and reading encrypted Array's.
Hope they are of some help.
Regards,
Paul
Code: Select all
------------------------------------------------------------------------------------------------------------------------------------------
// General Read and Write Encrypted File routines
------------------------------------------------------------------------------------------------------------------------------------------
command ReadFile tInPathAndFile InPassword @OutArrayData
put "binfile:"&tInPathAndFile into tBinPathFile
put URL tBinPathFile into tB64EncrArray
// Now Decrypt
DeCryptData tB64EncrArray, INPassword ,OutDecryptedEncodedArray
----
put arrayDecode(OutDecryptedEncodedArray) into OutArrayData
end ReadFile
--
Function ReadFile tInPathAndFile InPassword
put "binfile:"&tInPathAndFile into tBinPathFile
put URL tBinPathFile into tB64EncrArray
// Now Decrypt
DeCryptData tB64EncrArray, INPassword ,OutDecryptedEncodedArray
----
return arrayDecode(OutDecryptedEncodedArray)
end ReadFile
--
// Save data to file
command SaveFile tInPathAndFile InArrayData InPassword
put arrayEncode(InArrayData) into InEncArray
// Now Encrypt
EnCryptData InEncArray, InPassword, OutB64EncrData
----
delete file tInPathAndFile
put "binfile:"&tInPathAndFile into tBinPathFile
put OutB64EncrData into URL tBinPathFile
end SaveFile
----------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Encrypt and Decrypt Data to and from encrypted and base64 coded data (base64 coded data can be sent over the internet and put in databases without problems)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Command DeCryptData InB64EncrData, INPassword @OutDecryptedData
put base64Decode(InB64EncrData) into tEncrData
decrypt tEncrData using "aes-256-cbc" with password INPassword
put it into OutDecryptedData
end DeCryptData
--
Command EnCryptData InData, InPassword @OutB64EncrData
encrypt InData using "aes-256-cbc" with password InPassword
put base64Encode(It) into OutB64EncrData
end EnCryptData
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Re: Transferring an Array from desktop to mobile
Posted: Thu Feb 04, 2021 10:18 am
by elanorb
Hi Glenn
If the array data is read in from file you will probably want to include the initial version of the files in the Copy Files pane of the Standalone Application Settings. This will include the files in the standalone. You can then reference them using specialFolderPath("resources").
You can't write to specialFolderPath("resources") so you could copy them to specialFolderPath("documents") on the first run of the app and then load/save them from there.
Kind regards
Elanor
Re: Transferring an Array from desktop to mobile
Posted: Mon Feb 08, 2021 2:09 pm
by glenn9
I'm still tying myself up in knots trying to transfer the Array of my 'dictionary' app from desktop to mobile...
I've been trying to do this by saving the Array as a custom property using ArrayEncode and then trying to save it to the specialfoldpath("documents") on mobile so I can use the array in the mobile app.
However, not having much success!
Elanor's suggestion of including the Array file in the Copy Files pane of the Standalone Application Settings sounds a whole lot easier but I'm not sure i understand how to reference it using using specialFolderPath("resources") so I can then start using it within the app?
I was wondering whether anyone could show me some code snippets illustrating how to reference the included Standalone file using Elanor's suggestion?
Many thanks,
Kind regards,
Glenn
Re: Transferring an Array from desktop to mobile
Posted: Mon Feb 08, 2021 2:18 pm
by Klaus
Hi Glenn,
glenn9 wrote: ↑Mon Feb 08, 2021 2:09 pm
...
Elanor's suggestion of including the Array file in the Copy Files pane of the Standalone Application Settings sounds a whole lot easier but I'm not sure i understand how to reference it using using specialFolderPath("resources") so I can then start using it within the app?
...
really no rocket science!
Code: Select all
...
put specialfolderpath("resources") & "/your_encoded_array.bin" into tBinFile
put url(tBinFile) into tEncodedArrayData
## Dou your thing with tEncodedArrayData...
...
Best
Klaus
Re: Transferring an Array from desktop to mobile
Posted: Mon Feb 08, 2021 2:36 pm
by glenn9
Thanks Klaus, I'll give that a go...
Regards,
Glenn
Re: Transferring an Array from desktop to mobile
Posted: Mon Feb 08, 2021 2:41 pm
by Klaus
Sorry, forgot BINFILE:
Code: Select all
...
put specialfolderpath("resources") & "/your_encoded_array.bin" into tBinFile
put url("binfile:" & tBinFile) into tEncodedArrayData
## Dou your thing with tEncodedArrayData...
...
Re: Transferring an Array from desktop to mobile
Posted: Mon Feb 08, 2021 4:11 pm
by glenn9
Hi Klaus,
this has worked perfectly, thank you so much again for your help.
5 lines of code has sorted it all out...I'm embarrassed to disclose exactly how many hours I've spent over the last few days trying to solve this... I think almost as many hours as lines of code.... how do you say in Germany... Lehrgeld?
Kind regards,
Glenn
Re: Transferring an Array from desktop to mobile
Posted: Mon Feb 08, 2021 4:13 pm
by Klaus
Hi Glenn,
glad I could help, and yes, it is called "Lehrgeld" in german.
Best
Klaus
Re: Transferring an Array from desktop to mobile
Posted: Tue Mar 02, 2021 3:38 am
by liveme
AES 256 "generating" a distinct new string after each click ?
Hi guys,
I'm trying to figure out if AES 256 standard behaviour is to generate a new string after each click...eventhough all the parameters, InData, PW, etc...do not change ? (I'm not an expert in Cryptography

)
From the Sample script above I've build this one script :
Code: Select all
on mouseUp pButtonNumber
put "" into fld "Resu"
put "IsWhateverString" into InData
put "1234567890123456" into InPassword
encrypt InData using "aes-256-cbc" with password InPassword
put base64Encode(It) into OutB64EncrData
put OutB64EncrData into fld "Resu"
end mouseUp
after 3 clicks, I get :
U2FsdGVkX1/4095rcdk1F+pT4FpL+jkSPMIMZoG8sQbjUMitFQO29jkLV+QVPiTs
U2FsdGVkX1+OpzogjZFN66k/amYJJ4lsf8XAACu2lMvz3E/5rvYM0G0QLBU9NFxb
U2FsdGVkX1+pZJPEFc5FPfFfgYCKul6iWEsqoC4VXMN5SpC50I4tofH6Q4AD2BYZ
Isnt it weird to get dif. results ? or I made some error along the Script ?
*I had open this other Topic where, when using the AES 128 (128 !)...it always returns only one single answer.
viewtopic.php?f=7&t=35463&p=202428&hili ... 56#p202428
Thanks for your expertise....
Re: Transferring an Array from desktop to mobile
Posted: Tue Mar 02, 2021 6:41 am
by liveme
Okie..I could solve my pervious Topic after checking needed param config with this online tool : Great !
see : www devglan com online-tools aes-encryption-decryption
5 stars checking tool !