Merhaba, Ziyaretçi. Lütfen giriş yapın veya üye olun.
Aktivasyon mailiniz gelmediyse buraya tıklayın.
09, 2008, 01:59:48 am
42744 Mesaj 8090 Konu Gönderen: 17931 Üye
Son üye: medist
Turk-Php.Com Forum  |  Yardım Forumları  |  PHP Yardım Forumu  |  PHP Class Deposu  |  Veri <=> Crypto sınıfı « önceki sonraki »
Sayfa: [1] Yazdır
Yazan Konu: Veri <=> Crypto sınıfı  (Okunma Sayısı 1527 defa)
mcwebteam
PHP Stajyeri
**
Offline Offline

Mesaj Sayısı: 308


PHP && My-Sql && OOP && AJAX && FLEX


Üyelik Bilgileri WWW
Veri <=> Crypto sınıfı
« : 02, 2006, 06:06:45 pm »

Kendi yazdığım bir sınıf.
Bu sitede ve php.org.tr sitesinde yayınlamıştım.
Linkler:

http://www.turk-php.com/smf/index.php/topic,3709.0.html
http://www.php.org.tr/index.php?option=com_simpleboard&Itemid=26&func=view&id=6280&catid=11

Başlıklardan konuyu takip edebilirsiniz.

Çalışma mantığı veri girişi yapılır ve çıkışı şifrelenmiş halde olur. Sonradan eklediğim özellikle multi fonksiyonu  ile verinin kaç kez şifreleneceğini belirtebiliyorsunuz. Tabi geri döndürebilmek için bu değeri kullanarak çözebilirsiniz.

Kod:
<?php
/**
 * Erdem YAVUZ
 * E-mail : erdem@a1tradenetwork.com
 * Sınıf yazım tarihi 17 Ağustos 2006 
 */

//Global değişkeninde çağıralacak şekilde sınıf yaratılıyor.
$text2code = new text2code();
class 
text2code {  
    
var $str;
    var $specialchar '?';
    var $pregsplit  '/\?/';
    var $outstr ='';
    var $for '1';
    
function cod2ord()
{
   
    $str 
nl2br($str);
    
    $str 
preg_split('//',$this->str);
    $i 1;
    while ($i<count($str)-1) {
     $outstr .= ((ord($str[$i])*15 3) ).$this->specialchar;
        $i++;
    }
    $outstr substr($outstr,0,strlen($outstr)-1);
    $this->str $outstr;
    return $this->str;        
}

function 
cod2dec($type='0')
{
    $str    preg_split($this->pregsplit,$this->str);
    $i 0;
    if ($type == 0) {
     while ($i<count($str)) {
     $outstr .= decoct($str[$i]).$this->specialchar;
     $i++; 
        }
    }
    if ($type == 1) {
     while ($i<count($str)) {
     $outstr .= octdec($str[$i]).$this->specialchar;
     $i++; 
        }
    }
    
    $this
->str $outstr;
    return $this->str;    
}
function 
cod2hex($type='0')
{
    $str    preg_split($this->pregsplit,$this->str);
    $i 0;
    if ($type == 0) {
     while ($i<count($str)) {
     $outstr .= dechex($str[$i]).$this->specialchar;
     $i++; 
        }
    }
    if ($type == 1) {
     while ($i<count($str)) {
     $outstr .= hexdec($str[$i]).$this->specialchar;
     $i++; 
        }
    }
    
    $this
->str $outstr;
    return $this->str;
}
function 
code2base64encode()
{
    $this->outstr base64_encode(gzcompress($this->str,1));
    $this->str    '';
    return $this->outstr;    
}
function 
code2base64decode()
{
    
    $this
->str  gzuncompress(base64_decode($this->str));    
    
return $this->str;    
}
function 
decoding()
{
   
    
//$this->str = gzuncompress($this->str);
    $this->code2base64decode();
    $this->cod2hex(1);
    $this->cod2dec(1);
  
    $codes 
preg_split($this->pregsplit,$this->str);
    $i 0;
    while ($i<count($codes)) {
     $outstr .= chr((($codes[$i]*3))/15);
     $i++;
    }
    $outstr preg_replace('/\r\n/','<br />',$outstr);
    $this->str '';
    return $this->outstr=$outstr;
}
function 
coding()
{
    $i 0;
    while ($i<$this->for) {
    $this->cod2ord();
    $this->cod2dec();
    $this->cod2hex();
    $this->str $this->code2base64encode();
    $i++;
    }
    $sonuc $this->str;
    $this->str '';
    return $sonuc;
}
function 
multidecoding()
{
    $i 0;
    while ($i<$this->for) {
    $this->str $this->decoding();
    $i++;
    }
    $sonuc $this->str;
    $this->str'';
    return $this->outstr $sonuc;
}
function 
prnt()
{
    return print substr($this->outstr,0,strlen($this->outstr)-4);
}
}

function 
code($data,$kez '1',$pr='')
{
   global $text2code;
    
    $text2code
->str=$data;
    $text2code->for=$kez;
    $dir $text2code->coding();
    if (!empty($pr))
    $text2code->prnt();
    if (empty($pr))
    return $dir;
}
function 
decode($code='',$pr='',$multi '')
{
   global $text2code;

    if (!empty($code))
    $text2code->str=$code;
    if (!empty($multi)) {
    $text2code->for $multi;
    }
    if ($text2code->for == 1)
    $sonuc $text2code->decoding();
    if ($text2code->for >1)    
    $sonuc 
$text2code->multidecoding();
    if (!empty($pr))
    $text2code->prnt();
    if (empty($pr))
    return $sonuc;
}

$str 'Turk-PHP.com';

?>


<table width="500" style="width:500px;" border="0">
<tr>
<td style="font-size:11px;width:500px;font-family:verdana;color:#333333;">
<?php
$donen 
= (code($str,3));
?>

</td>
</tr>

<tr>
<td style="font-size:11px;width:500px;font-family:verdana;color:#333333;">
<?php
decode
($donen,1,3);
?>


</td>
</tr>

</table>

Kolay gelsin.
« Son Düzenleme: 02, 2006, 06:11:11 pm Gönderen: mcwebteam » Logged

Erdem
Php İzmir Grubu Kuralım (İzmir'den Arkadaşlarla)
http://www.a1tradenetwork.com
Jabber : mcwebteam@member.turk-php.com

http://www.youtube.com/v/jKaO_dyKIpA
RAS
Yeni Kullanıcılar
*
Offline Offline

Mesaj Sayısı: 7


Üyelik Bilgileri
Ynt: Veri <=> Crypto sınıfı
« Yanıtla #1 : 07, 2006, 03:43:24 am »

Erdem bu konuyu bana göndermedin galiba... Sanırım şifrelemeyle ilgili bir şey bu ve hiç anlamam  Lips Sealed . Yani anlayacağın iyi bir programcı da değilim. Copy-paste den biraz fazla olarak araştırıyorum sadece. Ama bunun benimle ilgili olduğunu sanmıyorum???!!!!

Logged

RAS
JAH BLESS YOU



Der Teufel steckt im Details
Sayfa: [1] Yazdır 
« önceki sonraki »
Gitmek istediğiniz yer:  


Turk-Php.Com Forum | SMF Forum Software © 2005, Simple Machines LLC. All Rights Reserved.