I'm developing a small project in android which is using php webservices' call.
I want my webservices to be protected, however by using GET/POST request methods I don't think its much protected. After googling I got RSA implementation in "phpseclib", Its having good documentation as well. But I'm confused so much, so thought post this here.
Basically what I need is:
- from Android I'l call a url with "encrypted parameters merged in one string". (I'l first encode parameters in json and then I'l encrypt).
- those parameters I'l extract in php, and process accordingly.
json string: {user_id:xyz@gmail.com, passwd: Password!}
encrypted to: XsjkhkjwehrkanmNXmnskjawrhjlljahdhuw
eg. http://my.domain.com/webservices/call.php?params=Xsjkhkjwehrkanm,NXmnskjawrhjlljahdhuw In php, I'l extract userID and Password, from that $_GET['params"']
This is possible in base64_encode(), base64_decode(),
but base64
encoder will just obfuscate the string, it won't encrypt actually.
I need public/private key mechanism.
However I've tried this: (https://launchkey.com/docs/api/encryption/php/phpseclib)
<?
function rsa_encrypt($key, $message) {
$rsa = new Crypt_RSA();
$rsa->loadKey($key);
$encrypted = base64_encode($rsa->encrypt($message));
return $encrypted;
}
?>
Its not returning any $encrypted string.
Any help would be really appreciated.
Thanks..! :)