Home  >  Article  >  php教程  >  php简单异或运算|php 简单异或|php异或|php xor

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

PHP中文网
PHP中文网Original
2016-05-23 16:38:584435browse

跳至

<?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);

                   

Statement:
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