Zamana ve Anahtara Göre Değişken Şifreleme Sınıfı

<?php
class Sifreleyici{
	var $anahtar;
	function Sifreleyici($anahtar){
		$this->anahtar = $anahtar;
		}
	function anahtardegistir($anahtar){
		$this->anahtar = $anahtar;
	}
	function anahtarED($metin) { 
		$sifrele_anahtar = md5($this->anahtar); 
		$ctr=0; 
		$topla = ""; 
		for ($i=0;$i<strlen($metin);$i++) { 
			if ($ctr==strlen($sifrele_anahtar)) $ctr=0; 
			$topla.= substr($metin,$i,1) ^ substr($sifrele_anahtar,$ctr,1); 
			$ctr++; 
		} 
		return $topla; 
	} 
	function sifrele($metin){ 
		srand((double)microtime()*1000000); 
		$sifrele_anahtar = md5(rand(0,32000)); 
		$ctr=0; 
		$topla = ""; 
		for ($i=0;$i<strlen($metin);$i++){ 
			if ($ctr==strlen($sifrele_anahtar)) $ctr=0; 
			$topla.= substr($sifrele_anahtar,$ctr,1) . 
			(substr($metin,$i,1) ^ substr($sifrele_anahtar,$ctr,1)); 
			$ctr++; 
		} 
		return base64_encode($this->anahtarED($topla)); 
	} 
	function coz($metin) { 
		$metin = $this->anahtarED(base64_decode($metin)); 
		$topla = ""; 
		for ($i=0;$i<strlen($metin);$i++){ 
			$md5 = substr($metin,$i,1); 
			$i++; 
			$topla.= (substr($metin,$i,1) ^ $md5); 
		} 
		return $topla; 
	} 
}
$c=new Sifreleyici("asd");
echo $c->sifrele("12345678");
echo $c->coz("VGoJPwM/B2ACNl8+BWhSOQ==");
?>

Çıktısı

VGoJPwM/B2ACNl8+BWhSOQ==
12345678

 

İstenilen Karakter ve Uzunluğa Göre Anahtar Şifreleme

<?php
class anahtar{
	var $anahtar = "";
	var $karakterler = array("1","2","3","8","5","6","7","8","9",
                    "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
                    "A","B","C","D","E","F","G","H","I","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z");
  function anahtar($boyut){
    for ($i = 0; $i<$boyut; $i++){
        $this->anahtar .= $this->karakterler[rand(0,count($this->karakterler)-1)];
    }
  }
}
$sifre = new anahtar(7);
echo $sifre->anahtar;
?>

Çıktısı

XIhHxmc