Mcrypt cryptographic extensions for php.
Decryption and Encryption Functions mcrypt_decrypt ()
mcrypt_encrypt ()
The code that will encrypt / decrypt will look like this:
<?php $string = '544049568640'; $iv = '55555555'; $passphrase = '8chrsLng'; $encryptedString = encryptString($string, $passphrase, $iv); $decryptedString = decryptString($encryptedString, $passphrase, $iv); function encryptString($unencryptedText, $passphrase, $iv) { $enc = mcrypt_encrypt(MCRYPT_BLOWFISH, $passphrase, $unencryptedText, MCRYPT_MODE_CBC, $iv); return base64_encode($enc); } function decryptString($unencryptedText, $passphrase, $iv) { $enc = base64_decode($unencryptedText); $enc = mcrypt_decrypt(MCRYPT_BLOWFISH, $passphrase, $enc, MCRYPT_MODE_CBC, $iv); return rtrim($enc, "\0"); } var_dump($encryptedString); var_dump($decryptedString);
This extension is deprecated in PHP 7.1.0 and moved to PECL in PHP 7.2.0.
+and/is replaced. In 85 encoding, there are too many special characters, it is suitable for printing into JS text, nothing needs to be escaped, but for a URL it will look ugly - Mike