Need an example of encryption between LiveCode and PHP

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 348
Joined: Sun Jul 03, 2011 2:04 am

Need an example of encryption between LiveCode and PHP

Post by keithglong » Sun Nov 23, 2014 12:43 am

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

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Need an example of encryption between LiveCode and PHP

Post by AxWald » Sun Nov 23, 2014 7:18 pm

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 ...
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 348
Joined: Sun Jul 03, 2011 2:04 am

Re: Need an example of encryption between LiveCode and PHP

Post by keithglong » Mon Nov 24, 2014 1:07 am

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

Post Reply