1

I'm trying to encrypt some data using crypt::encrypt in Laravel. I need to decrypt this encryption in iOS and Android apps. Any idea?

3

1 Answer 1

6

Short answer: it is a bad idea, do not do it.

A little more detailed: It makes no sense. Laravel uses AES for encryption, which is a symmetric key algorithm: the same key is required for encryption and decryption. If you want to decrypt anything on the client side, you need the key to be known to the client - this basically renders the whole server-side encryption useless. To give advice on what to do instead, we need to know what you're trying to achieve:

  • To transport the data securely between the Laravel-based server and the app? Use HTTPS.
  • For anything else, the most likely answer is to use asymmetric encryption like RSA.
Sign up to request clarification or add additional context in comments.

1 Comment

A better solution might be to encrypt the file on the server with a public key generated by the client: php.net/manual/en/function.openssl-public-encrypt.php And decrypt it with the private key known by the client.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.