Socket Packaging
Bob Sneidar
bobsneidar at iotecdigital.com
Fri Jun 28 12:44:24 EDT 2024
Added error checking. Also the payload can now be a string or an array.
command packagePayload @pPayload, pUseEncryption
try
if pPayload is an array then \
put arrayEncode(pPayload) into pPayload
if pUseEncryption then \
put slyEncrypt(pPayload) into pPayload
put base64Encode(pPayload) into pPayload
catch tError
return "ERROR:" && tError
end try
end packagePayload
command unpackPayload @pPayload, pUseEncryption
try
put base64Decode(pPayload) into pPayload
if pUseEncryption is true or pPayload begins with "salted" then \
put slyDecrypt(pPayload) into pPayload
if pPayload is an array then \
put arrayDecode(pPayload) into pPayload
catch tError
return "ERROR:" && tError
end try
end unpackPayload
Bob S
> On Jun 24, 2024, at 9:21 AM, Bob Sneidar <bobsneidar at iotecdigital.com> wrote:
>
> Hi all.
>
> I came up with deceptively simple wrappers for packaging data for transmission over raw sockets. I can’t send the slyEncrypt and slyDecrypt handlers because I use methods no one else knows. But you can roll your own or else eliminate encryption altogether.
>
> And to answer the question befor it’s asked, I don’t use SSL because I don’t like having to deal with certificates, and also because I use a method for encryption that I don’t think anyone else has thought of, or at least I can’t find any info online.
>
> Bob S
>
> command packagePayload @pPayload, pUseEncryption
> if pPayload is an array then \
> put arrayEncode(pPayload) into pPayload
>
> if pUseEncryption then \
> put slyEncrypt(pPayload) into pPayload
>
> put base64Encode(pPayload) into pPayload
> end packagePayload
>
> command unpackPayload @pPayload
> put base64Decode(pPayload) into pPayload
>
> if pPayload begins with "salted" then \
> put slyDecrypt(pPayload) into pPayload
>
> try
> put arrayDecode(pPayload) into tResult
> put tResult into pPayload
> catch tError
> -- not an array
> end try
> end unpackPayload
>
More information about the use-livecode
mailing list