Encryption
function encode($str,$key) { $res = base64_encode($str); $code = $res^$key; return $code; }
Decryption
function decode($str,$key) { return base64_decode($str^$key); }
Full code example:
$str = '111021'; $key = 'APPYJJ-PHONE-LAZY'; function encode($str,$key) { $res = base64_encode($str); $code = $res^$key; return $code; } $str = encode($str,$key); print_r($str); echo "<hr>"; function decode($str,$key) { return base64_decode($str^$key); } print_r(decode($str,$key));
The whole program is very simple~ According to logical thinking, it should be difficult to crack, if others don’t know your secret key;
If you still feel unsafe. So I’m just going to throw some light here; I suggest you continue to use shift operations in the encryption and decryption process
//加密的时候; $a = $str >> 4; //解密的时候则相反 $a = $str << 4;
ok!~ At this point, the blogger continues to work! ~~
Encryption
function encode($str,$key) { $res = base64_encode($str); $code = $res^$key; return $code; }
Decryption
function decode($str,$key) { return base64_decode($str^$key); }
Complete code example:
$str = '111021'; $key = 'APPYJJ-PHONE-LAZY'; function encode($str,$key) { $res = base64_encode($str); $code = $res^$key; return $code; } $str = encode($str,$key); print_r($str); echo "<hr>"; function decode($str,$key) { return base64_decode($str^$key); } print_r(decode($str,$key));
The whole program is very simple ~ according to logical thinking, it should be difficult to crack, in others Without knowing your secret key;
If you still feel unsafe. So I’m going to throw some light here; I suggest you continue to use shift operations in the encryption and decryption process
//加密的时候; $a = $str >> 4; //解密的时候则相反 $a = $str << 4;
For more related articles about sharing a newly written PHP encryption and decryption function, please pay attention to PHP Chinese website!