php encryption/decryption function Encryption/decryption function Usage var_dump(Fun::Jmen('aah',$_ENV['Only'])); var_dump(Fun::Jmun('ADYAsVzEX94%3D',$ _ENV['Only'])); Parameters: $str: str type, content that needs to be encrypted or decrypted $key: str type, key (the encryption and decryption keys must be the same) Return: str type , decrypted or decrypted content
- /**
- Encryption/decryption function
- Usage
- var_dump(Fun::Jmen('aah',$_ENV['Only']));
- var_dump(Fun::Jmun('ADYAsVzEX94%3D',$_ENV['Only' ]));
- Parameters:
- $str: str type, the content that needs to be encrypted or decrypted
- $key: str type, key (the encryption and decryption keys must be the same)
- Return:
- str type, decryption or decryption completed The content of
- /**/
- public static function Jmen($str,$key){
- $encrypt_key=md5(mt_rand(0,100));$ctr=0;$tmp='';
- for ($i=0;$i
- if($ctr==strlen($encrypt_key)){$ctr=0;}$tmp.=substr($encrypt_key,$ctr ,1).(substr($str,$i,1) ^ substr($encrypt_key,$ctr,1));$ctr++;
- }
- unset($encrypt_key,$ctr,$str);
- return rawurlencode( base64_encode(self::_m_($tmp,$key)));
- }
- public static function Jmun($str,$key){
- $txt=self::_m_(base64_decode(rawurldecode($str)),$ key);$tmp='';
- for($i=0;$i
- unset($txt,$md5,$str,$key);
- return $tmp;
- }
- private static function _m_($txt, $key){
- $key=md5($key);$ctr=0;$tmp='';
- for($i=0;$i
- return $tmp;
- }
Copy code
|