 |
ช่วยแปลง code vb.netเป็น phpหน่อยครับ แถมถอดรหัสด้วยนะครับ |
|
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2010-08-01 23:46:26 |
By :
airzio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมไม่แน่ใจแต่พอบอกได้คร่าวๆ ลองปรับแต่งดูไม่รู้ว่าจะตกหล่นตรงไหนหรือเปล่า 
Code (PHP)
function Encrypt($PlainText,$Key){
$PlainChar=array();
$Ascii=array();
for($Count=0;$Count<=strlen($PlainText)-1;$Count++){
if(ord(substr($PlainText,$Count,1))>=65 && ord(substr($PlainText,$Count,1))<=90){
$Ascii[$Count] = (($Ascii[$Count] - 65 + $Key) % 26) + 65;
}elseif(ord(substr($PlainText,$Count,1))>=97 && ord(substr($PlainText,$Count,1))<=122){
$Ascii[$Count] = (($Ascii[$Count] - 97 + $Key) % 26) + 97;
}
$PlainChar[$Count]=chr($Ascii[$Count]);
}
return $PlainChar;
}
สำหรับการถอดรหัส
$Ascii[$Count] = (26 + $Ascii[$Count] + $Key) % 26;
|
ประวัติการแก้ไข 2010-08-02 00:10:15 2010-08-02 01:39:59
 |
 |
 |
 |
Date :
2010-08-02 00:08:47 |
By :
chineji |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ทราบว่าลองrunยังครับพอดีผมลองrunแล้วมันไม่ได้อ่ะครับ
|
 |
 |
 |
 |
Date :
2010-08-02 16:55:53 |
By :
airzio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนเพิ่มการเข้ารหัสตัวเลขด้วยได้ไม๊ครับ
|
 |
 |
 |
 |
Date :
2010-08-02 16:59:41 |
By :
airzio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รันดูให้แล้วครับ
Code (PHP)
function Encrypt($PlainText,$Key){
for($Count=0;$Count<=strlen($PlainText)-1;$Count++){
if(ord(substr($PlainText,$Count,1))>=48 && ord(substr($PlainText,$Count,1))<=57){ //0-9
$Ascii[$Count] = ((ord(substr($PlainText,$Count,1)) - 48 + $Key) % 26) + 48;
}elseif(ord(substr($PlainText,$Count,1))>=65 && ord(substr($PlainText,$Count,1))<=90){ //A-Z
$Ascii[$Count] = ((ord(substr($PlainText,$Count,1)) - 65 + $Key) % 26) + 65;
}elseif(ord(substr($PlainText,$Count,1))>=97 && ord(substr($PlainText,$Count,1))<=122){//a-z
$Ascii[$Count] = ((ord(substr($PlainText,$Count,1)) - 97 + $Key) % 26) + 97;
}else{
$Ascii[$Count] = ord(substr($PlainText,$Count,1));
}
$PlainChar.=chr($Ascii[$Count]);
}
return $PlainChar;
}
function Decode($PlainText,$Key){
for($Count=0;$Count<=strlen($PlainText)-1;$Count++){
if(ord(substr($PlainText,$Count,1))>=48 && ord(substr($PlainText,$Count,1))<=57){//0-9
$decode[$Count]=(ord(substr($PlainText,$Count,1)) +48 - $Key) -48;
}elseif(ord(substr($PlainText,$Count,1))>=65 && ord(substr($PlainText,$Count,1))<=90){//A-Z
$decode[$Count]=(ord(substr($PlainText,$Count,1)) +65 - $Key) -65;
}elseif(ord(substr($PlainText,$Count,1))>=97 && ord(substr($PlainText,$Count,1))<=122){//a-z
$decode[$Count]=(ord(substr($PlainText,$Count,1)) +97 - $Key)-97;
}else{
$decode[$Count]=ord(substr($PlainText,$Count,1));
}
$DecodeChar.=chr($decode[$Count]);
}
return $DecodeChar;
}
$a= Encrypt("Kingkong07%#",1);
print $a."<br>"; //Ljohlpoh18%#
print Decode($a,1); //Kingkong07%#
|
ประวัติการแก้ไข 2010-08-02 23:11:41
 |
 |
 |
 |
Date :
2010-08-02 23:00:42 |
By :
chineji |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เพิ่มเติม
Code (PHP)
(int)$Key
กัน Error 
|
 |
 |
 |
 |
Date :
2010-08-02 23:14:05 |
By :
chineji |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆเลยครับ
|
 |
 |
 |
 |
Date :
2010-08-03 00:20:54 |
By :
airzio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|