Php encrypted/decrypted data
Php encryption/decryption function
Data encryption/decryption
Usage
Var_dump (Fun: Jmen ('A', $ _ ENV ['only']);
Var_dump (Fun: Jmun ('adyasvzex94% 3D ', $ _ ENV ['only']);
Metric data:
$ Str: str type, content to be encrypted or decrypted
$ Key: str type, password secret (the password for encryption and decryption must be the same)
Return value:
Str type, decrypted or decrypted content
- /**
- Data encryption/decryption
- Usage
- Var_dump (Fun: Jmen ('A', $ _ ENV ['only']);
- Var_dump (Fun: Jmun ('adyasvzex94% 3D ', $ _ ENV ['only']);
- Metric data:
- $ Str: str type, content to be encrypted or decrypted
- $ Key: str type, password secret (the password for encryption and decryption must be the same)
- Return value:
- Str type, decrypted or decrypted content
- /**/
- 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;
- }
|
Php