-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,631
  • 9
  • 26
  • 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,744
  • 2
  • 23
  • 32
1

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

Mchl
  • 61,444
  • 9
  • 118
  • 120