PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
Datenaustausch mit PHP über 2 Server
Beitrag
<blockquote data-quote="stroyer" data-source="post: 1023785" data-attributes="member: 263373"><p><strong>AW: Datenaustausch mit PHP über 2 Server</strong></p><p></p><p>Die Sicherheit ist zur Zeit noch etwas problematisch. So könnte jeder, der das System kennt deine Daten auslesen bzw. auch löschen.</p><p>Ich würde zusätzlich zur Query auch noch einen Hash oder so übertragen. Alternativ könntest du die Query per RC verschlüsseln und einen MD5-Hash mitliefern.</p><p> </p><p>Hier noch ein Source für eine RC-Verschlüsselung:</p><p>[php]</p><p><?php</p><p> function Byte($x)</p><p> {</p><p> if($x>255)</p><p> {</p><p> return $x % 256;</p><p> }</p><p> else</p><p> {</p><p> if($x<0)</p><p> {</p><p> return 256 + ($x % 256);</p><p> }</p><p> else</p><p> {</p><p> return $x;</p><p> }</p><p> }</p><p> }</p><p> function RoundD($int)</p><p> {</p><p> return Round($int-0.5);</p><p> }</p><p> function shr($x, $y)</p><p> {</p><p> for($i=0;$i<$y;$i++)</p><p> {</p><p> $x=RoundD($x/2);</p><p> }</p><p> return $x;</p><p> }</p><p> function RCxInitRaw($Key, $KeySize)</p><p> {</p><p> $L=0;</p><p> for($S=0;$S<256;$S++)</p><p> {</p><p> $RCx[0][$S] = $S;</p><p> $M[$S] = Byte($Key[$S % $KeySize] ^ $L);</p><p> $L = ($L + $M[$S]*257) % 2147483647 + 1;</p><p> }</p><p> $RCx[1] = 0;</p><p> $RCx[2] = 0;</p><p> $R = Byte($L);</p><p> $RCx[3] = Byte(shr($L, 8));</p><p> for($S=0;$S<256;$S++)</p><p> {</p><p> $R = Byte($R + $RCx[0][$S] + $M[$S]);</p><p> $T = $RCx[0][$S];</p><p> $RCx[0][$S] = $RCx[0][$R];</p><p> $RCx[0][$R] = $T;</p><p> }</p><p> return $RCx;</p><p> }</p><p> function RCxInit($Key)</p><p> {</p><p> for($i=0;$i<strlen($Key);$i++)</p><p> {</p><p> $ar[$i] = ord(substr($Key,$i,1));</p><p> }</p><p> return RCxInitRaw($ar,$i);</p><p> }</p><p> function RCxEncodeRawRaw($RCx, $S, $count)</p><p> {</p><p> for($C=0;$C<$count;$C++)</p><p> {</p><p> $RCx[1] = Byte($RCx[1] + 1);</p><p> $T = $RCx[0][$RCx[1]];</p><p> $RCx[2] = Byte($RCx[2] + $T);</p><p> $RCx[0][$RCx[1]] = $RCx[0][$RCx[2]] ^ $RCx[3];</p><p> $RCx[0][$RCx[2]] = Byte($T - $RCx[3]);</p><p> $T = Byte($T + $RCx[0][$RCx[1]]);</p><p> $K = $S[$C];</p><p> $O[$C] = $K ^ $RCx[0][$T];</p><p> $RCx[3] = $RCx[3] ^ $K;</p><p> }</p><p> $res[0] = $RCx;</p><p> $res[1] = $O;</p><p> return $res;</p><p> }</p><p> function RCxEncodeRaw($RCx, $val)</p><p> {</p><p> for($i=0;$i<strlen($val);$i++)</p><p> {</p><p> $ar[$i] = ord(substr($val,$i,1));</p><p> }</p><p> $ret=RCxEncodeRawRaw($RCx, $ar, $i);</p><p> $str='';</p><p> for($i=0;$i<strlen($val);$i++)</p><p> {</p><p> if($ret[1][$i]>15)</p><p> {</p><p> $str.=base_convert($ret[1][$i],10,16);</p><p> }</p><p> else</p><p> {</p><p> $str.='0'.base_convert($ret[1][$i],10,16);</p><p> }</p><p> }</p><p> return $str;</p><p> }</p><p> function RCxDecodeRawRaw($RCx, $S, $count)</p><p> {</p><p> for($C=0;$C<$count;$C++)</p><p> {</p><p> $RCx[1] = Byte($RCx[1] + 1);</p><p> $T = $RCx[0][$RCx[1]];</p><p> $RCx[2] = Byte($RCx[2] + $T);</p><p> $RCx[0][$RCx[1]] = $RCx[0][$RCx[2]] ^ $RCx[3];</p><p> $RCx[0][$RCx[2]] = Byte($T - $RCx[3]);</p><p> $T = Byte($T + $RCx[0][$RCx[1]]);</p><p> $K = $S[$C] ^ $RCx[0][$T];</p><p> $O[$C] = $K;</p><p> $RCx[3] = $RCx[3] ^ $K;</p><p> }</p><p> $res[0] = $RCx;</p><p> $res[1] = $O;</p><p> return $res;</p><p> }</p><p> function RCxDecodeRaw($RCx, $val, $ofs)</p><p> {</p><p> for($i=0;$i<strlen($val)/2;$i++)</p><p> {</p><p> $ar[$i]=base_convert(substr($val,$i*2,2),16,10);</p><p> }</p><p> $ret=RCxDecodeRawRaw($RCx, $ar, $i);</p><p> $val=$ret[1];</p><p> $str='';</p><p> for($j=$ofs;$j<$i;$j++)</p><p> {</p><p> $str.=chr($val[$j]);</p><p> }</p><p> return $str;</p><p> }</p><p> function RCxEncode($val, $key, $offs)</p><p> {</p><p> if($offs<0 || isset($offs)==false)</p><p> {</p><p> $offs=16;</p><p> }</p><p> $val=RandomString($offs).$val;</p><p> $RCx=RCxInit($key);</p><p> $ret=RCxEncodeRaw($RCx, $val);</p><p> return $ret;</p><p> }</p><p> function RCxDecode($val, $key, $offs)</p><p> {</p><p> if($offs<0 || isset($offs)==false)</p><p> {</p><p> $offs=16;</p><p> }</p><p> $RCx=RCxInit($key);</p><p> $ret=RCxDecodeRaw($RCx, $val, $offs);</p><p> return $ret;</p><p> }</p><p> function RandomString($len)</p><p> {</p><p> $rand='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';</p><p> $str='';</p><p> for($i=0;$i<$len;$i++)</p><p> {</p><p> $str.=substr($rand,rand(0,strlen($rand)-1),1);</p><p> }</p><p> return $str;</p><p> }</p><p> function Hex16ToHex32($hex)</p><p> {</p><p> $hex32='0123456789ABCDEFGHKLMNOPRSTUVWXZ';</p><p> $key='';</p><p> $hex=strtoupper($hex);</p><p> for($i=0;$i<strlen($hex)/5;$i++)</p><p> {</p><p> $t=strpos($hex32,substr($hex,$i*5+4,1))+strpos($hex32,substr($hex,$i*5+3,1))*16+strpos($hex32,substr($hex,$i*5+2,1))*16*16+strpos($hex32,substr($hex,$i*5+1,1))*16*16*16+strpos($hex32,substr($hex,$i*5,1))*16*16*16*16;</p><p> $res[1]=substr($hex32,RoundD($t/(32*32*32)),1);</p><p> $t%=32*32*32;</p><p> $res[2]=substr($hex32,RoundD($t/(32*32)),1);</p><p> $t%=32*32;</p><p> $res[3]=substr($hex32,RoundD($t/32),1);</p><p> $t%=32;</p><p> $res[4]=substr($hex32,$t,1);</p><p> $key.='-'.$res[1].$res[2].$res[3].$res[4];</p><p> }</p><p> return substr($key,1);</p><p> }</p><p> function Hex32ToHex16($hex)</p><p> {</p><p> $hex32='0123456789ABCDEFGHKLMNOPRSTUVWXZ';</p><p> $key='';</p><p> $hex=strtoupper($hex);</p><p> for($i=0;$i<strlen($hex)/5;$i++)</p><p> {</p><p> $t=strpos($hex32,substr($hex,$i*5+3,1))+strpos($hex32,substr($hex,$i*5+2,1))*32+strpos($hex32,substr($hex,$i*5+1,1))*32*32+strpos($hex32,substr($hex,$i*5,1))*32*32*32;</p><p> $res[1]=substr($hex32,RoundD($t/(16*16*16*16)),1);</p><p> $t%=16*16*16*16;</p><p> $res[2]=substr($hex32,RoundD($t/(16*16*16)),1);</p><p> $t%=16*16*16;</p><p> $res[3]=substr($hex32,RoundD($t/(16*16)),1);</p><p> $t%=16*16;</p><p> $res[4]=substr($hex32,RoundD($t/16),1);</p><p> $t%=16;</p><p> $res[5]=substr($hex32,$t,1);</p><p> $key.=$res[1].$res[2].$res[3].$res[4].$res[5];</p><p> }</p><p> return $key;</p><p> }</p><p> function RCxEncode32($val, $key, $offs)</p><p> {</p><p> $val=strlen($val).'|'.$val;</p><p> while((strlen($val)+$offs) % 5 != 0)</p><p> {</p><p> $val.='0';</p><p> }</p><p> return Hex16ToHex32(RCxEncode($val, $key, $offs));</p><p> }</p><p> function RCxDecode32($val, $key, $offs)</p><p> {</p><p> $val=RCxDecode(Hex32ToHex16($val), $key, $offs);</p><p> $i=0;</p><p> $c='';</p><p> while(substr($val,$i,1)!='|')</p><p> {</p><p> $c.=substr($val,$i,1);</p><p> $i++;</p><p> }</p><p> $i++;</p><p> return substr($val,$i,$c*1);</p><p> while(substr($val,strlen($val)-1,1)==chr(0))</p><p> {</p><p> $val=substr($val,0,strlen($val)-1);</p><p> }</p><p> return $val;</p><p> }</p><p> function Encode($value,$password)</p><p> {</p><p> return RCxEncode32($value,$password,12);</p><p> }</p><p> function Decode($value,$password)</p><p> {</p><p> return RCxDecode32($value,$password,12);</p><p> }</p><p>?></p><p>[/php]</p><p> </p><p>Aufruf mit Encode und Decode;</p><p>Vorteil: Selbst bei gleicher Query wird etwas anderes übertragen (Nur Zeichen von 0 bis Z)</p></blockquote><p></p>
[QUOTE="stroyer, post: 1023785, member: 263373"] [b]AW: Datenaustausch mit PHP über 2 Server[/b] Die Sicherheit ist zur Zeit noch etwas problematisch. So könnte jeder, der das System kennt deine Daten auslesen bzw. auch löschen. Ich würde zusätzlich zur Query auch noch einen Hash oder so übertragen. Alternativ könntest du die Query per RC verschlüsseln und einen MD5-Hash mitliefern. Hier noch ein Source für eine RC-Verschlüsselung: [php] <?php function Byte($x) { if($x>255) { return $x % 256; } else { if($x<0) { return 256 + ($x % 256); } else { return $x; } } } function RoundD($int) { return Round($int-0.5); } function shr($x, $y) { for($i=0;$i<$y;$i++) { $x=RoundD($x/2); } return $x; } function RCxInitRaw($Key, $KeySize) { $L=0; for($S=0;$S<256;$S++) { $RCx[0][$S] = $S; $M[$S] = Byte($Key[$S % $KeySize] ^ $L); $L = ($L + $M[$S]*257) % 2147483647 + 1; } $RCx[1] = 0; $RCx[2] = 0; $R = Byte($L); $RCx[3] = Byte(shr($L, 8)); for($S=0;$S<256;$S++) { $R = Byte($R + $RCx[0][$S] + $M[$S]); $T = $RCx[0][$S]; $RCx[0][$S] = $RCx[0][$R]; $RCx[0][$R] = $T; } return $RCx; } function RCxInit($Key) { for($i=0;$i<strlen($Key);$i++) { $ar[$i] = ord(substr($Key,$i,1)); } return RCxInitRaw($ar,$i); } function RCxEncodeRawRaw($RCx, $S, $count) { for($C=0;$C<$count;$C++) { $RCx[1] = Byte($RCx[1] + 1); $T = $RCx[0][$RCx[1]]; $RCx[2] = Byte($RCx[2] + $T); $RCx[0][$RCx[1]] = $RCx[0][$RCx[2]] ^ $RCx[3]; $RCx[0][$RCx[2]] = Byte($T - $RCx[3]); $T = Byte($T + $RCx[0][$RCx[1]]); $K = $S[$C]; $O[$C] = $K ^ $RCx[0][$T]; $RCx[3] = $RCx[3] ^ $K; } $res[0] = $RCx; $res[1] = $O; return $res; } function RCxEncodeRaw($RCx, $val) { for($i=0;$i<strlen($val);$i++) { $ar[$i] = ord(substr($val,$i,1)); } $ret=RCxEncodeRawRaw($RCx, $ar, $i); $str=''; for($i=0;$i<strlen($val);$i++) { if($ret[1][$i]>15) { $str.=base_convert($ret[1][$i],10,16); } else { $str.='0'.base_convert($ret[1][$i],10,16); } } return $str; } function RCxDecodeRawRaw($RCx, $S, $count) { for($C=0;$C<$count;$C++) { $RCx[1] = Byte($RCx[1] + 1); $T = $RCx[0][$RCx[1]]; $RCx[2] = Byte($RCx[2] + $T); $RCx[0][$RCx[1]] = $RCx[0][$RCx[2]] ^ $RCx[3]; $RCx[0][$RCx[2]] = Byte($T - $RCx[3]); $T = Byte($T + $RCx[0][$RCx[1]]); $K = $S[$C] ^ $RCx[0][$T]; $O[$C] = $K; $RCx[3] = $RCx[3] ^ $K; } $res[0] = $RCx; $res[1] = $O; return $res; } function RCxDecodeRaw($RCx, $val, $ofs) { for($i=0;$i<strlen($val)/2;$i++) { $ar[$i]=base_convert(substr($val,$i*2,2),16,10); } $ret=RCxDecodeRawRaw($RCx, $ar, $i); $val=$ret[1]; $str=''; for($j=$ofs;$j<$i;$j++) { $str.=chr($val[$j]); } return $str; } function RCxEncode($val, $key, $offs) { if($offs<0 || isset($offs)==false) { $offs=16; } $val=RandomString($offs).$val; $RCx=RCxInit($key); $ret=RCxEncodeRaw($RCx, $val); return $ret; } function RCxDecode($val, $key, $offs) { if($offs<0 || isset($offs)==false) { $offs=16; } $RCx=RCxInit($key); $ret=RCxDecodeRaw($RCx, $val, $offs); return $ret; } function RandomString($len) { $rand='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $str=''; for($i=0;$i<$len;$i++) { $str.=substr($rand,rand(0,strlen($rand)-1),1); } return $str; } function Hex16ToHex32($hex) { $hex32='0123456789ABCDEFGHKLMNOPRSTUVWXZ'; $key=''; $hex=strtoupper($hex); for($i=0;$i<strlen($hex)/5;$i++) { $t=strpos($hex32,substr($hex,$i*5+4,1))+strpos($hex32,substr($hex,$i*5+3,1))*16+strpos($hex32,substr($hex,$i*5+2,1))*16*16+strpos($hex32,substr($hex,$i*5+1,1))*16*16*16+strpos($hex32,substr($hex,$i*5,1))*16*16*16*16; $res[1]=substr($hex32,RoundD($t/(32*32*32)),1); $t%=32*32*32; $res[2]=substr($hex32,RoundD($t/(32*32)),1); $t%=32*32; $res[3]=substr($hex32,RoundD($t/32),1); $t%=32; $res[4]=substr($hex32,$t,1); $key.='-'.$res[1].$res[2].$res[3].$res[4]; } return substr($key,1); } function Hex32ToHex16($hex) { $hex32='0123456789ABCDEFGHKLMNOPRSTUVWXZ'; $key=''; $hex=strtoupper($hex); for($i=0;$i<strlen($hex)/5;$i++) { $t=strpos($hex32,substr($hex,$i*5+3,1))+strpos($hex32,substr($hex,$i*5+2,1))*32+strpos($hex32,substr($hex,$i*5+1,1))*32*32+strpos($hex32,substr($hex,$i*5,1))*32*32*32; $res[1]=substr($hex32,RoundD($t/(16*16*16*16)),1); $t%=16*16*16*16; $res[2]=substr($hex32,RoundD($t/(16*16*16)),1); $t%=16*16*16; $res[3]=substr($hex32,RoundD($t/(16*16)),1); $t%=16*16; $res[4]=substr($hex32,RoundD($t/16),1); $t%=16; $res[5]=substr($hex32,$t,1); $key.=$res[1].$res[2].$res[3].$res[4].$res[5]; } return $key; } function RCxEncode32($val, $key, $offs) { $val=strlen($val).'|'.$val; while((strlen($val)+$offs) % 5 != 0) { $val.='0'; } return Hex16ToHex32(RCxEncode($val, $key, $offs)); } function RCxDecode32($val, $key, $offs) { $val=RCxDecode(Hex32ToHex16($val), $key, $offs); $i=0; $c=''; while(substr($val,$i,1)!='|') { $c.=substr($val,$i,1); $i++; } $i++; return substr($val,$i,$c*1); while(substr($val,strlen($val)-1,1)==chr(0)) { $val=substr($val,0,strlen($val)-1); } return $val; } function Encode($value,$password) { return RCxEncode32($value,$password,12); } function Decode($value,$password) { return RCxDecode32($value,$password,12); } ?> [/php] Aufruf mit Encode und Decode; Vorteil: Selbst bei gleicher Query wird etwas anderes übertragen (Nur Zeichen von 0 bis Z) [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ▲ = 7, ▼ = 3, ◇ = 2 und die Summe von ▲ und ▼ durch ◇ geteilt wird, was ist das Ergebnis?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
Datenaustausch mit PHP über 2 Server
Oben