RSA Encrypt and Decrypt Strings on Android

2019-02-14 02:16发布

问题:

I'm reading pages and pages since weeks but I cannot find a solution. I want "only" to:

  1. Make my own public and private keys to encrypt and decrypt strings between my PHP website and Android application (like on http://www.example-code.com/android/rsa_generateKey.asp but how can I store and use the generated keys?)
  2. Encrypt a string on my application
  3. Decrypt the string from my website
  4. Encrypt a string on my website
  5. Decrypt the string from my application

I've just found a class that does simply this job ( http://www.example-code.com/android/rsa_encryptStrings.asp ) but it is not free, and to make it work on PHP I should install a PHP extension but I can't on my web hosting.

Is there something similar? I'm studying a lot but I don't know why I don't understand how to do it in different ways.

Probably something similar to

RSA Android Encrypt / RSA PHP Decrypt

could help but it is not the complete source code.

Please give me some real working examples.

回答1:

this should do it.

http://www.javamex.com/tutorials/cryptography/rsa_encryption.shtml
http://www.javamex.com/tutorials/cryptography/rsa_encryption_2.shtml

It's not an android question, much more Java.