-1

If my variable looks like this:

$name = "John";

and I want the above variable, to be encrypted to something like:

 encrypt($name) //Will output something like: AIfzx353HA7f (Just random chars)

And then, be able to decrypt it, so it will output John again.

decrypt($name) //Will output John

Is this possible to do with PHP?

Oliver 'Oli' Jensen
  • 2,551
  • 9
  • 24
  • 40

2 Answers2

2

You can use different types of algorithms to do this. Maybe you can take a look at Mcrypt here. (in particular mcrypt_encrypt and mcrypt_decrypt)

Cydonia7
  • 3,586
  • 2
  • 21
  • 32
1

There's mcrypt extension that supports a variety of cryptographic functions.

Mchl
  • 60,035
  • 9
  • 112
  • 119