Home > php教程 > PHP源码 > php简单异或运算|php 简单异或|php异或|php xor

php简单异或运算|php 简单异或|php异或|php xor

PHP中文网
Release: 2016-05-23 16:38:58
Original
4470 people have browsed it

跳至

<?php

function getXOR($data, $key, $string = &#39;&#39;){
		$len = strlen($data);
		$len2 = strlen($key);
		for($i = 0; $i < $len; $i ++){
			$j = $i % $len2;
			$string	.= ($data[$i]) ^ ($key[$j]);
		}	
		return $string;
}


$data = &#39;this is a #test@ string&#39;;
$key = &#39;thisakey&#39;;



$f = getXOR($data, $key);
echo $f;
$s = getXOR($f, $key);
print_r($s);
Copy after login

                   

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template