encrypt and decrypt on iOS

Dar Scott dsc at swcp.com
Sat Apr 26 17:59:15 CEST 2014


Oh, and consider doing the same for the string to be encrypted if consists of characters.  

On Apr 26, 2014, at 9:54 AM, Dar Scott <dsc at swcp.com> wrote:

> Hi, Sims!
> 
> Are you planning for 7.0?
> 
> Currently, and on 7.0 dp2, both the source and the password (passphrase) in the syntax you point out are byte strings.  (And, if you use a key, it is a fixed length byte string.)
> 
> The password is usually interpreted as characters and is typically longer than a key.
> 
> If you limit your passphrase character set to ASCII, you are good for moving to 7.0.  Use it as your password.  (You can still move to Unicode later.)
> 
> If you want to go full Unicode, you can use unicodeText and uniEncode to convert to UTF-8 for the password.  When you move to 7.0, change that to a single textEncode().  You can upgrade from ASCII with with the ability to decrypt old data..  
> 
> But if you are using your native 8-bit coding, you can have both cross platform problems and uniCode limitations.  If you use your 8-bit encoding directly, you won’t be able to move to full Unicode with general compatibility with past passwords.  You have already used up all 8 bits in the bytes.  If you think you want to eventually move to full unicode, start converting to UTF-8 now.  
> 
> So, in summary I recommend either ASCII or UTF-8 for the password parameter.
> 
> There may be some standards in the works concerning key generation (from passprhases) but this is good for your internal use.
> 
> Dar
> 
> 
> 
> 
> On Apr 26, 2014, at 9:05 AM, Jim sims <sims at ezpzapps.com> wrote:
> 
>> Mike - thanks loads :-)
>> 
>> I was trying to use the dictionary syntax:
>> 
>> *Syntax: *
>> 
>> encrypt *source* using *cipher* with [password|key] *passorkey *[and salt
>> saltvalue] [and IV *IVvalue*] [at *bitvalue* bit]
>> 
>> I found your explanation much more friendly, in fact got it working first
>> shot.
>> 
>> We think alike - I already use Monte's mergEXT, excellent Man & stuff. Also
>> plan on using the DropBox method for some things. Wanted to learn the
>> native LiveCode version however, i like to go native whenever i can  ;-)
>> 
>> Is there a webpage for the DropBox REST api effort you refer to?
>> 
>> Thanks again,
>> 
>> sims
>> 
>> 
>> On Sat, Apr 26, 2014 at 3:53 PM, Mike Kerner <MikeKerner at roadrunner.com>wrote:
>> 
>>> One more thing - don't forget to decode before you decrypt.
>>> 
>>> 
>>> On Sat, Apr 26, 2014 at 9:52 AM, Mike Kerner <MikeKerner at roadrunner.com
>>>> wrote:
>>> 
>>>> Jim,
>>>> 
>>>> There are two ways to do encryption on ios in LC:
>>>> 1) Monte has an encryption external in his mergEXT suite
>>>> 2) You can use the native code.  The native code uses OpenSSL.  Due to
>>>> some technical issues it CAN be less secure than the libraries that Monte
>>>> is using, but that is something for you to decide.
>>>> 
>>>> You should also encode the encrypted data (AFTER encryption) to ensure
>>>> that it transports properly.
>>>> 
>>>> The syntax looks like this, assuming:
>>>> * The data you want to encrypt is in "what"
>>>> * The cipher you want to use is aes-256
>>>> * The key you want to use to do the encryption is in "theKey"
>>>> 
>>>> 
>>>> encrypt what using "aes-256-cbc" with theKey
>>>> put base64encode(it) into what #v. 1.6 was bit16
>>>> 
>>>> 
>>>> From here you would either embed "what" into an email or write to a file
>>>> and attach the file.
>>>> 
>>>> 
>>>> If it was me, and I was helping you, I would suggest that you do not send
>>>> email from ios, but that you use dropbox, because if you send email, your
>>>> user will get a chance to see the email and thus screw something up,
>>> maybe
>>>> by sending the encrypted data to somewhere else, or if you are directly
>>>> embedding the "what" container in an email, by accidentally deleting or
>>>> adding a character, or maybe a helpful introduction like "Here's the
>>>> email", which will screw up your decryption, of course.
>>>> 
>>>> Dropbox integration is fairly straightforward.  Monte has a couple of
>>>> externals in the mergEXT suite, and there is also an open-source library
>>>> that several of us have worked on that works (but it is arguably not as
>>>> fast as Monte's external, because it relies on Dropbox's REST API, so
>>> your
>>>> app will, in effect, have to sit there while the file(s) transfer).
>>>> 
>>>> 
>>>> 
>>>> On Sat, Apr 26, 2014 at 3:16 AM, Jim sims <sims at ezpzapps.com> wrote:
>>>> 
>>>>> Am trying to figure out how to use the new Encrypt/Decrypt with iOS.
>>>>> 
>>>>> I want to encrypt a few hundred words of data then send as a file
>>>>> attachment via email. I have zero idea what PEM format and such are.
>>>>> 
>>>>> Anyone have a stack that shows how this is done?
>>>>> 
>>>>> Would be great to have example stacks for new commands and features when
>>>>> new versions come out.
>>>>> 
>>>>> sims
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> use-livecode at lists.runrev.com
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> On the first day, God created the heavens and the Earth
>>>> On the second day, God created the oceans.
>>>> On the third day, God put the animals on hold for a few hours,
>>>>  and did a little diving.
>>>> And God said, "This is good."
>>>> 
>>> 
>>> 
>>> 
>>> --
>>> On the first day, God created the heavens and the Earth
>>> On the second day, God created the oceans.
>>> On the third day, God put the animals on hold for a few hours,
>>>  and did a little diving.
>>> And God said, "This is good."
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list