Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

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



 

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

 



Topic : 046249

Guest




เป็นcodeเข้ารหัส แบบซีซ่าอ่ะครับ

Code (VB.NET)
Function Encrypt(ByVal PlainText As String, ByVal Key As Byte) As String
'แปลง plaintext ที่เป็น string ให้เป็น array ของตัวอักษร
Dim PlainChar() As Char = PlainText.ToCharArray()
Dim Ascii(PlainChar.Length) As Byte

For Count As Byte = 0 To PlainChar.Length - 1
'แปลงตัวอักษรเป็นรหัส ASCII ที่เป็นตัวเลข
Ascii(Count) = CByte(Asc(PlainChar(Count)))

'คัดเฉพาะตัวอักษร A-Z และ a-z นอกนั้นไม่มีการเข้ารหัส
'A-Z มีรหัส ASCII เป็น 65-90
'a-z มีรหัส ASCII เป็น 97-122
If Ascii(Count) >= 65 And Ascii(Count) <= 90 Then 
Ascii(Count) -= 65 'ให้ A-Z มีค่าเริ่มต้นจาก 0 ถึง 25 ตามลำดับ
Ascii(Count) = (Ascii(Count) + Key) Mod 26 Ascii(Count) += 65
'สามารถเขียนให้อยู่ในบรรทัดเดียวได้
'Ascii(Count) = ((Ascii(Count) - 65 + Key) Mod 26) + 65
ElseIf Ascii(Count) >= 97 And Ascii(Count) <= 122 Then
Ascii(Count) -= 97 'ให้ a-z มีค่าเริ่มต้นจาก 0 ถึง 25 ตามลำดับ
Ascii(Count) = (Ascii(Count) + Key) Mod 26 
Ascii(Count) += 97
'สามารถเขียนให้อยู่ในบรรทัดเดียวได้
'Ascii(Count) = ((Ascii(Count) - 97 + Key) Mod 26) + 97
End If

'แปลงตัวเลข ASCII กลับเป็นตัวอักษร
PlainChar(Count) = Chr(Ascii(Count))
Next

'ส่งค่าตัวอักษรที่เป็น array กลับเป็น string
Return PlainChar
End Function

สำหรับการถอดรหัสให้เปลี่ยนจาก
Ascii(Count) = (Ascii(Count) + Key) Mod 26
เป็น
Ascii(Count) = (26 + Ascii(Count) + Key) Mod 26





Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-07-31 16:29:36 By : airzio View : 2022 Reply : 7
 

 

No. 1

Guest









แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-08-01 23:46:26 By : airzio
 


 

No. 2



โพสกระทู้ ( 318 )
บทความ ( 2 )



สถานะออฟไลน์
Facebook

ผมไม่แน่ใจแต่พอบอกได้คร่าวๆ ลองปรับแต่งดูไม่รู้ว่าจะตกหล่นตรงไหนหรือเปล่า
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
 

 

No. 3

Guest


ไม่ทราบว่าลองrunยังครับพอดีผมลองrunแล้วมันไม่ได้อ่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-08-02 16:55:53 By : airzio
 


 

No. 4

Guest


รบกวนเพิ่มการเข้ารหัสตัวเลขด้วยได้ไม๊ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-08-02 16:59:41 By : airzio
 


 

No. 5



โพสกระทู้ ( 318 )
บทความ ( 2 )



สถานะออฟไลน์
Facebook

รันดูให้แล้วครับ
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
 


 

No. 6



โพสกระทู้ ( 318 )
บทความ ( 2 )



สถานะออฟไลน์
Facebook

เพิ่มเติม
Code (PHP)
(int)$Key

กัน Error
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-08-02 23:14:05 By : chineji
 


 

No. 7

Guest


ขอบคุณมากๆเลยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-08-03 00:20:54 By : airzio
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยแปลง code vb.netเป็น phpหน่อยครับ แถมถอดรหัสด้วยนะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่