Page 1 of 1

Need an example of encryption between LiveCode and PHP

Posted: Sun Nov 23, 2014 12:43 am
by keithglong
Hi All,

Would anyone out there be able to provide an example demonstrating the encryption/decryption of text strings between a LiveCode app and a PHP script? I have been playing around with various PHP snippets and a stack using LiveCode's encrypt command, but I just can't seem to sync things up between the two systems. I am sure a lot of folks out there could use such an example.

Thanks,

- Boo

Re: Need an example of encryption between LiveCode and PHP

Posted: Sun Nov 23, 2014 7:18 pm
by AxWald
Hi,

dunno if it helps this much, but I had to re-code a PhP function recently:

PHP:

Code: Select all

<?php
function generateHash()
{

    $initKey = 'EXsl4ywgDR5mR3sTGwws9Ikl2ocSKZlvhxoFTv8Au3MaV5UqrEIJORVF5PmFNy';
    $remoteDomain = 'www.server.de';
    $date = gmdate('dmY');
    $hash = "";

    for($i = 0; $i <= 200; $i++)
        $hash = sha1($hash . $initKey . $remoteDomain . $date);

    return $hash;
}
?> 
Livecode:

Code: Select all

on mouseUp

   put "EXsl4ywgDR5mR3sTGwws9Ikl2ocSKZlvhxoFTv8Au3MaV5UqrEIJORVF5PmFNy" into MyKey
   put "www.server.de" into MyServer
   put "07112014" into MyDate       //better a real date ...
   put empty into MyHash
   put 0 into mycounter
   put the ticks into MyTicks
   
   repeat for 201
      get sha1digest(MyHash & MyKey & MyServer & MyDate)
      put empty into MyVar
      put binarydecode("H*",it,MyVar) into myOtherVar       // Voodoo (stolen) :)
      put MyVar into MyHash
      add 1 to Mycounter
   end repeat
   put the Ticks into EndTicks
   Put MyHash & " / " & MyCounter & " / Time: " & Endticks - Myticks into fld "output_fld"
   
end mouseUp
It's no encryption, only hashing, but it may give you an idea. I hope!

Have fun!

Edit: Pressed "submit" too fast ...

Re: Need an example of encryption between LiveCode and PHP

Posted: Mon Nov 24, 2014 1:07 am
by keithglong
Hi AxWald,

Thanks for the input. Hashing can be quite useful at times... However, such a scheme does not meet the needs of my current project. :-(

This is an awesome forum. Thanks again.

Sincerely,

- Boo