B4A Library crypt b4a and php

Here attached an example of how to encrypt and decrypt using b4a and php.
test_xn_crypt.zip is the android application.
ws_execute.zip is the php web service.
I hope it can be useful.
Should you have any question ...
:)
 

Attachments

  • test_xn_crypt.zip
    2.2 KB · Views: 494
  • ws_execute.zip
    1.1 KB · Views: 467

Shay

Well-Known Member
Licensed User
Longtime User
Hi
Thank you for this code,
I adjusted it to work with HttpUtils2
I have problem with PHP code

on app, without your code I used this:
ExecuteRemoteQuery("action=1&DeviceID=" & DeviceID ,"Post1")

Now I am using this:
B4X:
req="action=1&DeviceID=" & DeviceID
Enc = GlobalCode.xn_trim_encrypt (req)
ExecuteRemoteQuery(Enc ,"Post1")

on php server I used:
B4X:
    $action=$_POST['action'];
    $DeviceID=$_POST['DeviceID'];

Now I don't know what to do after:
$i = xn_trim_decrypt ( file_get_contents ( "php://input" ) ) ;

Meaning how to I get $action and $DeviceID from $i
 

Shay

Well-Known Member
Licensed User
Longtime User
Ok, I think I figure it,
on app I change it to:
req="1," & DeviceID

on php I am doing:
B4X:
$a = explode(",", $i);
    $action=$a[0];
    $DeviceID=$a[1];
 

Shay

Well-Known Member
Licensed User
Longtime User
Hi
Thanks
Can you provide the class also for B4i?
 

Shay

Well-Known Member
Licensed User
Longtime User
:-( after I make this to work...

do you have some example for doing the same with SSL?
 
Top