Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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);
share|improve this question
This is what TLS is for. – user1615903 May 6 at 9:36
this is more like university project, so this dont have to be 100% professional. TLS requires extra configuration, that i wont be able to do on university server. Or do i get it wrong? – Silent Cave May 6 at 9:39
2  
Ok I see. Check this SO question: stackoverflow.com/questions/4484246/… – user1615903 May 6 at 9:41
ok, and how do i generate key pair? – Silent Cave May 6 at 9:46
If you're running on Windows, PuttyGen is good. – user1615903 May 6 at 9:46
show 6 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.