skip to content

PHP: Encryption and Decryption Example

On this page we are demonstrating how we can use our Cryptor class to encrypt, transmit and decrypt a simple message. The steps involved are: encrypt, transmit, decrypt.

Working Encryption Example

Step 1.

Enter a short string here that you want to encrypt and transmit:

Text to be encrypted

This form submits your string using Ajax to a server-side script for encryption:

<?PHP $encryption_key = '...'; $cipher_method = '...'; $cryptor = new \Chirp\Cryptor($encryption_key, $cipher_method); $crypted = $cryptor->encrypt($token); ?>


The strings encrypted on this page can only be decrypted here and not on another server because you will be missing the encryption key, which is specific to this page, and the cipher method used.

Similarly if you encrypt a string on your server using your own cipher method and encryption key it will not decode here.

In order to decrypt data using openssl_decrypt you need to know both those values.


Post your comment or question