gi-crypt

Gesponsorde koppelingen

PHP script bestanden

  1. gi-crypt

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php

class g_i_crypt
{


##################These are tools##################


//correct the octet

protected function fixoctet($bin){

    //if you dont put this value first in a var a error wil occur
    $len = (8 - strlen($bin));

    for($i = 0; $i < $len ; $i++){
    
        $bin = "0".$bin;
    }

    

    return $bin;
}



//makes the key binary
protected function key2octet($key){


    for($o = 0; $o < $this->key_len; $o++){
    
        
        $key_temp = decbin(ord($key[$o]));
        $this->bin_key[$o] = self::fixoctet($key_temp);

    }
    
}



//makes the data binary
protected function data2octet($data){


    for($o = 0; $o < $this->data_len; $o++){
    
        
        $data_temp = decbin(ord($data[$o]));
        $this->bin_data[$o] = self::fixoctet($data_temp);
        

    }
    
}


//converts the binary data to readable
protected function octet2data($data){


    $this->output_data = "";
    
    while(list($key,$value) = each($data)){
        $this->output_data .= chr(bindec($value));
    }
    
}



//blends the two octets together
protected function blendoctet($octet1,$octet2){

    
    for($i = 0; $i < sizeof($octet1); $i++){
        
        $key_pos = $i % sizeof($this->bin_key);
        
        for($o = 0; $o < 8; $o++){
        
            if($octet2[$key_pos][$o] == "1" && $octet1[$i][$o] == "0"){
                $octet1[$i][$o] = "1";
                continue;
            }

            
            if($octet2[$key_pos][$o] == "1" && $octet1[$i][$o] == "1"){
                $octet1[$i][$o] = "0";
                continue;
            }

            
            if($octet2[$key_pos][$o] == "0" && $octet1[$i][$o] == "0"){
                $octet1[$i][$o] = "0";
                continue;
            }

            
            if($octet2[$key_pos][$o] == "0" && $octet1[$i][$o] == "1"){
                $octet1[$i][$o] = "1";
                continue;
            }
        }
    }

    
    $this->output_data = $octet1;
}



##################This is where its about##################


//encrypt the data

public function encrypt($data,$key){

    //data length
    $this->data_len = strlen($data);
    
    //key length
    $this->key_len = strlen($key);
    
    
    //makes the key binary
    self::key2octet($key);
    
    //makes the data binary
    self::data2octet($data);
    
    //blends the password with the data
    self::blendoctet($this->bin_data,$this->bin_key);
    
    //converts the binary data to readable data
    self::octet2data($this->output_data);
    
    //Hmm wondering what this does :P
    return $this->output_data;
    
}



//decrypt the data
public function decrypt($data,$key){

    return self::encrypt($data,$key);
    
}




//end of class
}

$class = new g_i_crypt();
$data = $class->encrypt("G-Interfaces.com","chessere");
echo $data."<br/>";
$data = $class->decrypt($data,"chessere");
echo $data."<br/>";

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.