Encrypt in php and decrypt in javascript

Asked

Viewed 507 times

0

Want to store in a text file, at the root of my application, a key generated by PHP, as a salt.

That key would help encrypt passwords, database access information. That is, such information would be encrypted to be used by PHP.

Se necessite de acesso o banco de dados através do javascript, usaria este salt para descriptografar as informações e effecto o acesso, lendo diretamente do arquivo de texto.

My doubt

Is it possible that some value encrypted in PHP can be decrypted in javascript and vice versa? How can it be done, and which algorithm to use?

Is there any standard to traffic information between the two languages (PHP and javascript)?

  • 3

    It is to run in a browser, IE, is a website? Because the javascript that is accessed by the client in the browser can be read without restriction, ie without security.

  • Yes. Exactly that. My idea was to do this in a safe way.

  • The question doesn’t seem to define a goal, in fact little of it makes any sense. TLS/SSL already does exactly what it’s asking. TLS uses a temporary key (or not, in some Cipher old suite) for each connection (using DH, DHE, ECDHE or X25519), encrypt the data using the key and then the server decrypts the data with such a key. That is, the client sends encrypted data to the server.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.