1.写文件

 $fp = fopen("jsapi_ticket.json", "w+");
 fwrite($fp, $str);
 fclose($fp);

 2.导出数据(使用header函数)

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment;filename=pc_collection_".$nodeid.'.txt');
echo base64_encode(json_encode($data));

 3.解决base_decode 解密可能出现的中文乱码问题

mb_convert_encoding(base64_decode($v),"UTF-8","gb2312");

 4.异或加密 解密

function xor_enc($str,$key){
	$crytxt = '';
	$keylen = strlen($key);
	for($i=0;$i<strlen($str);$i++){  
		$k = $i % $keylen;
		$crytxt .= $str[$i] ^ $key[$k];
	}
	return $crytxt;
}


$str = "北京欢迎您";
$key = "Welcome";
$crytxt = xor_enc($str,$key);
echo "加密后->".$crytxt;
echo "<br>";
echo "解密后->".xor_enc($crytxt,$key);

 

相关文章:

  • 2021-12-12
  • 2022-01-16
  • 2021-11-10
  • 2021-05-22
  • 2021-11-26
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-03
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案