1

I am looking for a simple and lightweight method of encrypting a string with javascript then decrypting with PHP after it's been sent in a header. With code for both JS and PHP parts.

There is no need for security as it's merely a means to obscure the string in the header.

XOR seems to be the best/lightest way. There are plenty of examples with incomplete answers.

The easiest answer seems to be the required PHP to decode this answer of the JS part: Simple Javascript encrypt, PHP decrypt with shared secret key

Open to any other lightweight methods.

Community
  • 1
  • 1
amcc
  • 2,608
  • 1
  • 20
  • 28

1 Answers1

1

If you XOR it, chances are you'll end up with invalid characters in your headers.

If you don't need security, what is wrong with good ol' base64_encode()/base64_decode()? There are plenty of Javascript equivalent codes out there...

DaveRandom
  • 87,921
  • 11
  • 154
  • 174
  • Thanks, my question was pretty stupid in hindsight but this did the job in the end^ – amcc Oct 15 '12 at 23:56