1. Hello Guest, selamat datang di Forum WinPoin. Kamu bisa bertanya, berdiskusi, sharing, dan ngobrolin apapun seputar Windows, Windows Phone, PC, Gadget, atau hal seputar Teknologi lainnya. Selamat berkomunitas! ;)

Ask Membuat Form Login dengan vb.net (2010)

Discussion in 'Developer Corner' started by BlankBoy, Oct 10, 2015.

  1. BlankBoy

    BlankBoy New Member

    Joined:
    Aug 13, 2015
    Messages:
    14
    Selamat siang agan-agan semua.
    Bagaimana membuat form login sederhana dengan vb.net (2010)? Yang nggak make database MySQL, Access atau database lainnya tetapi hanya make file teks biasa yang di enkripsi.
    Dulu di vb 6 ane pernah bikin, databasenya make file teks yg di enkripsi. Jadi pengen bikin juga di vb .net (2010) kek gitu, ada yang bisa bantu?
     
  2. ElangSBP

    ElangSBP Well-Known Member

    Joined:
    May 4, 2015
    Messages:
    1,059
    Hmm... Teman Saya Pernah Buat Dulu Tapi Saya Lupa Caranya
     
  3. mabaega

    mabaega Well-Known Member

    Joined:
    Nov 9, 2013
    Messages:
    2,737
    sudah sampe dimana buatnya om...
    mudah2an saya bisa bantu...

    Coba ini om..
    Serialize/DeSerialize Data Object.

    Buat Sebuah Project
    Buka Form1 Design
    Tambahkan 2 textbox dan 1 Button untuk merekam data
    Tambahkan 1 Datagridview untuk menampilkan data
    Tambahkan 2 textbox dan 1 button untuk mencoba login

    Penampakan Form
    Serialize.png

    Tambahkan 1 Class (ClsLogin), 1 Module (GlobalMod)
    Copas Code sesuai Nama modulnya

    Form1
    Code:
    PublicClassForm1
    
    PrivateSub Button1_Click(sender AsObject, e AsEventArgs) Handles Button1.Click
    
    Dim lstLogin AsNewList(OfClsLogin)
    
    lstLogin = Open_Data()
    
    Dim oLogin AsNewClsLogin()
    
    oLogin.sNamaLogin = TextBox1.Text
    
    oLogin.sPassword = TextBox2.Text
    
    lstLogin.Add(oLogin)
    
    Simpan_Data(lstLogin)
    
    DataGridView1.DataSource = lstLogin
    
    EndSub
    
    PrivateSub Button2_Click(sender AsObject, e AsEventArgs) Handles Button2.Click
    
    Dim lstLogin AsNewList(OfClsLogin)
    
    lstLogin = Open_Data()
    
    ForEach dl AsClsLoginIn lstLogin
    
    If dl.sNamaLogin = TextBox3.Text AndAlso dl.sPassword = TextBox4.Text Then
    
    MsgBox("Login Terdaftar!")
    
    ExitFor
    
    EndIf
    
    Next
    
    EndSub
    
    PrivateSub Form1_Load(sender AsObject, e AsEventArgs) HandlesMyBase.Load
    
    Dim LstLogin AsNewList(OfClsLogin)
    
    LstLogin = Open_Data()
    
    DataGridView1.DataSource = LstLogin
    
    EndSub
    
    EndClass
    
    ClsLogin
    Code:
    <System.Serializable()>
    
    PublicClassClsLogin
    
    Private _snamalogin AsString
    
    Private _sPassword AsString
    
    PublicProperty sNamaLogin AsString
    
    Get
    
    Return AES_Decrypt(_snamalogin, "123")
    
    EndGet
    
    Set(value AsString)
    
    _snamalogin = AES_Encrypt(value, "123")
    
    EndSet
    
    EndProperty
    
    PublicProperty sPassword AsString
    
    Get
    
    Return AES_Decrypt(_sPassword, "123")
    
    EndGet
    
    Set(value AsString)
    
    _sPassword = AES_Encrypt(value, "123")
    
    EndSet
    
    EndProperty
    
    PublicSubNew()
    
    EndSub
    
    EndClass
    
    
    
    
    GlobalMod
    Code:
    
    Imports System.IO
    
    Imports System.Runtime.Serialization.Formatters.Binary
    
    ModuleGlobalMod
    
    PublicFunction MyPath() AsString
    
    Dim sPath AsString = System.Windows.Forms.Application.ExecutablePath
    
    sPath = System.IO.Path.GetDirectoryName(sPath)
    
    If sPath.EndsWith("\bin\Debug") Then
    
    sPath = sPath.Substring(0, Len(sPath) - 10)
    
    ElseIf sPath.EndsWith("\bin\Release") Then
    
    sPath = sPath.Substring(0, Len(sPath) - 12)
    
    EndIf
    
    Return sPath
    
    EndFunction
    
    PublicFunction Open_Data() AsList(OfClsLogin)
    
    Dim LstLogin AsNewList(OfClsLogin)
    
    IfFile.Exists(MyPath() & "\test.bin") Then
    
    Dim bf AsNewBinaryFormatter()
    
    Dim fsRead AsNewFileStream(MyPath() & "\test.bin", FileMode.Open)
    
    LstLogin = bf.Deserialize(fsRead)
    
    fsRead.Close()
    
    Else
    
    MsgBox("File Data Password belum tersedia")
    
    EndIf
    
    Return LstLogin
    
    EndFunction
    
    PublicSub Simpan_Data(lst AsList(OfClsLogin))
    
    'Simpan Data Ke File
    
    Dim fs AsFileStream = NewFileStream(MyPath() & "\test.bin", FileMode.OpenOrCreate)
    
    Dim bf AsNewBinaryFormatter()
    
    bf.Serialize(fs, lst)
    
    fs.Close()
    
    EndSub
    
    PublicFunction AES_Encrypt(ByVal input AsString, ByVal pass AsString) AsString
    
    Dim AES AsNew System.Security.Cryptography.RijndaelManaged
    
    Dim Hash_AES AsNew System.Security.Cryptography.MD5CryptoServiceProvider
    
    Dim encrypted AsString = ""
    
    Try
    
    Dim hash(31) AsByte
    
    Dim temp AsByte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
    
    Array.Copy(temp, 0, hash, 0, 16)
    
    Array.Copy(temp, 0, hash, 15, 16)
    
    AES.Key = hash
    
    AES.Mode = Security.Cryptography.CipherMode.ECB
    
    Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
    
    Dim Buffer AsByte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
    
    encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
    
    Return encrypted
    
    Catch ex AsException
    
    EndTry
    
    EndFunction
    
    PublicFunction AES_Decrypt(ByVal input AsString, ByVal pass AsString) AsString
    
    Dim AES AsNew System.Security.Cryptography.RijndaelManaged
    
    Dim Hash_AES AsNew System.Security.Cryptography.MD5CryptoServiceProvider
    
    Dim decrypted AsString = ""
    
    Try
    
    Dim hash(31) AsByte
    
    Dim temp AsByte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
    
    Array.Copy(temp, 0, hash, 0, 16)
    
    Array.Copy(temp, 0, hash, 15, 16)
    
    AES.Key = hash
    
    AES.Mode = Security.Cryptography.CipherMode.ECB
    
    Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
    
    Dim Buffer AsByte() = Convert.FromBase64String(input)
    
    decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
    
    Return decrypted
    
    Catch ex AsException
    
    EndTry
    
    EndFunction
    
    EndModule
    
    Isi File Test.bin terencrypt , dibuka pakai Notepad
    Code:
       ÿÿÿÿ    JWindowsApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null  System.Collections.Generic.List`1[[WindowsApplication1.ClsLogin, WindowsApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]  _items_size_version  WindowsApplication1.ClsLogin[]               WindowsApplication1.ClsLogin       
      WindowsApplication1.ClsLogin  _snamalogin
    _sPassword    QfUZnB6RGNDJkysy4b9oHg==  QfUZnB6RGNDJkysy4b9oHg==      CKopi0p6FLS1AxnB+InRtw==  CKopi0p6FLS1AxnB+InRtw==
    
    Full Code Sources VS2015 Check Attachment
    tinggal dikembangkan saja om, sesuai kebutuhan.

    NB. to Mod..
    Gemana yach kalau mau upload script code?
    '
    Code:
    '
     

    Attached Files:

    Last edited: Oct 10, 2015
  4. Z.A.Y

    Z.A.Y Moderator Staff Member

    Joined:
    May 21, 2014
    Messages:
    1,796
    :v kamu maunya enkripsi berbentuk MD5 atau SHA atau DES

    textnya yang di enkripsi atau filetextnya
     
  5. BlankBoy

    BlankBoy New Member

    Joined:
    Aug 13, 2015
    Messages:
    14
    Lengkap nih om, ntar ane coba deh. Tapi ini bukan cuma form log in aja y? Nggak apa-apa deh,buat referensi...:D
     
  6. BlankBoy

    BlankBoy New Member

    Joined:
    Aug 13, 2015
    Messages:
    14
    File text atau textnya juga g masalah, yang penting biar g bisa dibaca orang aja. Enkripsi SHA aja gan, atau MD5 juga bole lah. Yg sederhana aja, tapi cuman kita yg tau cara dekripsinya.
     

Share This Page