7

Android KeyPairGenerator + php openssl_public_encrypt

view full story
linux-howto

http://stackoverflow.com – I have a client (android device) that generates a public+private key pair. It sends the public key to a server and the server should encrypt some data using the public key and return it so the client can decrypt it using the private key later. My php code logs a warning stating that the public key I am providing it is invalid. On the device side, I generate the key pair as follows - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(256); KeyPair kp = kpg.generateKeyPair(); PublicKey publicKey = kp.getPublic(); I then base64 encode and POST it - String urlParameter (HowTos)