Results 1 to 2 of 2

Thread: ASP.NET: ถามเรื่องการเข้ารหัสข้อมูลเพื่อเก็บใน SQL Server ครับ

  1. #1


    ไม่ทราบว่า asp.net มี built-in function ที่ใช้ในการเข้ารหัสข้อมูล (เช่น password, account number) ก่อนเก็บไว้ใน sql database ไหมครับ แนะนำด้วยครับ

    0x90
    tonynuc

    ...

  2. #2
    Jedi Global Moderator
    Join Date
    Aug 2007
    Location
    Bangkok
    Posts
    136


    มีครับ ปกติเห็นใช้ MD5 ในการเข้ารหัสและ ถอดรหัส ลองหา code ใน Internet โดย search คำว่า MD5 +ASP.Net เห็นมีตัวอย่างอยู่เต็มเลยครับ
    <%@ Import Namespace="System.Security.Cryptography" %>
    <%@ Import Namespace="System.Text" %>
    <script language="VB" runat="server">
    Sub DisplayEncryptedText(sender as Object, e as EventArgs)
    If Page.IsValid then
    Dim md5Hasher as New MD5CryptoServiceProvider()

    Dim hashedDataBytes as Byte()
    Dim encoder as New UTF8Encoding()

    hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(txtPassword.Text))

    ltlResults.Text = "Encrypted Results
    The results are encrypted into " & _
    "an array of 16 bytes. These 16 bytes contain the values:

    • "

      Dim b as Byte
      For Each b in hashedDataBytes
      ltlResults.Text &= "
    • " & b & ""
      Next b

      ltlResults.Text &= "
    "
    End If
    End Sub
    </script>

    <form runat="server">
    Enter a string:
    <asp:TextBox id="txtPassword" runat="server" />
    <asp:RequiredFieldValidator runat="server" ControlToValidate="txtPassword"
    Display="Dynamic" ErrorMessage="You must provide a value here..." />
    <asp:RegularExpressionValidator runat="server" ControlToValidate="txtPassword"
    Display="Dynamic" ErrorMessage="The string must be 20 characters or less..."
    ValidationExpression="^.{1,20}$" />


    <asp:Button runat="server" Text="View the String as Encrypted Text"
    OnClick="DisplayEncryptedText" />



    <asp:Literal runat="server" id="ltlResults" />
    </form>


Similar Threads

  1. Replies: 4
    Last Post: 31-03-2010, 03:06 PM
  2. ขอข้อมูลการทำ proxy server ครับ
    By system32 in forum Operating System, Server and Networking
    Replies: 4
    Last Post: 25-08-2009, 09:27 AM
  3. เกี่ยวกับไฟล์ server ครับ
    By Capton_wanderer in forum Hacking, Exploit Articles/Tutorial/Techniques
    Replies: 0
    Last Post: 17-09-2005, 10:42 AM
  4. เรื่อง Ftp server ครับ
    By studenmts in forum Operating System, Server and Networking
    Replies: 0
    Last Post: 15-04-2005, 07:13 PM
  5. มีปัญหาในการติดต่อ server ครับ
    By Anonymous in forum Symbian C++, J2ME, Brew,XHTML
    Replies: 0
    Last Post: 26-11-2004, 02:35 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •