encrypt not working in Leopard - temporary solution suggestion
Josh Mellicker
josh at dvcreators.net
Fri Dec 14 22:55:12 EST 2007
Thanks Mark, that is far superior.
On Dec 14, 2007, at 7:31 PM, Mark Smith wrote:
> Josh, this came up during the summer, and here is an RC4
> implementation. It's 'symetrical' - (you use the same function in
> and out). You'll need to base64encode the output if you're sending
> over the internet, and base64Decode back again before decrypting.
>
> put base64Encode(rc4(somePlainData, someSecretKey)) into
> someEncryptedData
> ....
> put rc4(base64Decode(someEncrypedData), someSecretKey) into
> somePlainData
>
>
>
>
> function rc4 pText, pKey
> -- initialize
> repeat with i = 0 to 255
> put i into S1[i]
> end repeat
>
> put 0 into i
> repeat with n = 0 to 255
> add 1 to i
> if i > length(pkey) then put 1 into i
> put charToNum(char i of pKey) into S2[n]
> end repeat
>
> put 0 into j
> repeat with i = 0 to 255
> put (j + S1[i] + S2[i]) mod 256 into j
> put S1[i] into temp
> put S1[j] into S1[i]
> put temp into S1[j]
> end repeat
>
> -- encrypt/decrypt
> put 0 into i ; put 0 into j
> repeat for each char c in pText
> put charToNum(c) into tChar
>
> put (i + 1) mod 256 into i
> put (j + S1[i]) mod 256 into j
> put S1[i] into temp
> put S1[j] into S1[i]
> put temp into S1[j]
> put (S1[i] + S1[j]) mod 256 into t
> put S1[t] into K
>
> put numToChar(tChar bitXor K) after tOutput
> end repeat
>
> return tOutput
> end rc4
>
>
> Best,
>
> Mark
>
> On 15 Dec 2007, at 02:59, Josh Mellicker wrote:
>>
>>
>> If anyone has something better, post it if ya got it!
>>
>>
>>
>>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list