Encrypt and Decrypt Strings in PHP
 05 September 2017
 Php
 Rodrigo Costa Corrêa

I've created two functions that use native methods of PHP, mycrypt_encode and mycrypt_decode, to encrypt and decrypt Strings in PHP. When a String is passed to the function, the string is encrypted / decrypted 3 times. To increase this amount of processing, simply change the value in the for loop.

Function to Encrypt:
public static function mycrypt_encode($str) {
		for($i = 0; $i < 3; $i ++) {
			$str = strrev ( base64_encode ( $str ) );
		}
		return $str;
	}
Function to Decrypt:
public static function mycrypt_decode($str) {
		for($i = 0; $i < 3; $i ++) {
			$str = base64_decode ( strrev ( $str ) );
		}
		return $str;
	}
Use Example:
$var = mycrypt_encode("YOUR_STRING");
$var = mycrypt_decode("YOUR_ENCRYPTED_STRING");