Encrypting long text

Sean Cole sean at pidigital.co.uk
Thu Dec 16 12:09:01 EST 2021

Thanks Mark,

New problem. Trying to use aes-256-ctr instead. I'm following the syntax in
the dictionary but it throws a red cross on it:

encrypt tData using "aes-256-ctr" with key tMyKey and salt tMySalt

What is wrong with this syntax that the auto language detector shows it as
a mistake?

On Thu, 16 Dec 2021 at 16:45, Mark Waddingham via use-livecode <
use-livecode at lists.runrev.com> wrote:

> On 2021-12-16 16:23, Sean Cole via use-livecode wrote:
> > Hi all,
> > I'm trying to use RSA to encrypt data from a text field like an address
> > or
> > notes. When I try to use the encrypt command I get a result 'message
> > too
> > long'. What is the method for encrypting long or large data?
> >
> > My current line of code:
> >                encrypt tData using rsa with public key tMyKey and
> > passphrase tMyPass
> RSA encryption can only encrypt data up to a certain length (I can't
> remember off the top of my head the exact relation, but it is related to
> the size of the key) so it isn't designed to be used on arbitrary length
> messages.
> Encrypting arbitrary length messages is the domain of symmetric
> encryption functions - like AES and friends.
> The solution, therefore, is to combine the two:
>    1) Generate a random (using randomBytes()) fixed length encryption key
> FixedKey
>    2) Encrypt the actual data using a symmetric algorithm with FixedKey
> as password
>    2) Use RSA to encrypt the (fixed length!) key FixedKey
>    4) Make you message the RSA-encrypted FixedKey followed by the
> encrypted data
> The RSA encrypted FixedKey will be a constant length, and thus you can
> just split that off of the combined data, decrypt it using RSA and then
> use the result to decrypt the payload.
> Hope this helps!
> Mark.
> --
> Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
> _______________________________________________
> 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