skip to content

PHP: Encryption and Decryption Example

 Tweet Share0 Tweets

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 use \Chirp\Cryptor; $encryption_key = '...'; $cipher_method = '...'; $cryptor = new Cryptor($encryption_key, $cipher_method); $crypted = $cryptor->encrypt($token); ?>

Portability

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.

< PHP

Send a message to The Art of Web:


used only for us to reply, and to display your gravatar.

<- copy the digits from the image into this box

press <Esc> or click outside this box to close

Post your comment or question
top