Let's say there's a shop and a bank. The shop wants to know if the client has sent money to their account, so:
- The shop send's the encrypted username and password to the bank using the public key.
- The bank decrypts the information using the private key.
- If the credentials are right, the bank sends back the shop's logs.
Now, how do I do that with PHP? How do I generate the key pair, and how do I decrypt/encrypt strings using them?
By the way, I'm using CodeIgniter. Maybe there's a built-in functions?
Pseudocode:
SHOP:
$public_key = file_get_contents(shop/key...);
$contents = encrypt($name+' '+$password,$public_key);
$log = file_get_contents('bank/get_history?secure='+$contents);
BANK:
$private_key = file_get_contents(bank/key...);
$credentials = decrypt($_GET['secure'],$private_key);
echo $this->model->get_logs($credentials);