08-03-2011, 11:55 AM
Code:
Imports System.IO 'Import untuk penanganan Input Output File, dsb...
Imports System.Text
Imports System.Security.Cryptography
Public Class Form1
'API Function
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As String, ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long
'Variable public pada Class Form1
Dim Pass As String 'tampung password ke memory....
Dim Done As Boolean 'ada password atau belum
Dim Chg As Boolean 'cek perubahan password
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
Dim Op As StreamReader 'penanganan Read File
Dim NOp As StreamWriter 'penangan Write File
Dim Encrypt As String
Dim SourceTStext As String
If cmdOK.Text = "Cancel" Then 'Tidak jadi merubah password
cmdOK.Text = "Login"
cmdChange.Text = "Change Password"
Label1.Text = "Password:"
txtPass.Focus()
Exit Sub
End If
If Done = False Then 'Buat File pass.txt
NOp = File.CreateText(Application.StartupPath & "\pass.txt") 'Buat File
NOp.Write(Encrypt(txtPass.Text)) 'Tulis File
NOp.Flush() 'Bersihkan stream reader pada file
NOp.Close() 'Tutup File
MsgBox("Password has been created!" & vbCrLf & "Please Login Now!")
txtPass.Text = ""
Done = True 'Beri paramater True agar bisa langsung login
cmdOK.Text = "Login"
cmdChange.Visible = True
txtPass.Focus()
Else 'File pass.txt sudah dibuat
Op = File.OpenText(Application.StartupPath & "\pass.txt") 'Buka File
Pass = Op.ReadToEnd 'Baca File dan letakkan di memory datanya
Op.Close() 'Tutup File
If Pass = Encrypt(txtPass.Text) Then 'Password benar
MsgBox("Correct Password")
REM; Routine untuk un-protect CD
Else
MsgBox("Wrong Password!")
mciSendString("set cd door open", 0, 0, 0)
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'-----------Always On Top---------
Me.TopMost = False
Dim proc As Process = Process.Start("notepad.exe")
proc.WaitForExit()
proc.Close()
Me.TopMost = True
SaveSetting("EliteSpy+", "Settings", "AlwaysOnTOp", "1")
'--------------------------------
Dim NOp As StreamWriter 'penangan Write File
Dim Encrypt As String
Dim SourceTStext As String
txtPass.Focus()
NOp = File.CreateText(Application.StartupPath & "\pass.txt") 'Buat File
NOp.Write(Encrypt(txtPass.Text)) 'Tulis File
NOp.Flush() 'Bersihkan stream reader pada file
NOp.Close() 'Tutup File
MsgBox("Password has been created!" & vbCrLf & "Please Login Now!")
'If File.Exists(Application.StartupPath & "\pass.txt") = False Then
'artinya (file) password belum dibuat! (pass.txt)
'Application.StartupPath = App.Path >> VB6
If cmdChange.Visible = False Then
cmdOK.Text = "Make Password!"
Done = False 'beri parameter di cmdOK bahwa password blm dibuat
Else
cmdChange.Visible = True
cmdOK.Text = "Login"
Done = True 'beri parameter sudah ada password
End If
End Sub
Private Sub cmdChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdChange.Click
Dim Op As StreamReader
Dim NOp As StreamWriter
Dim Encrypt As String
Dim SourceTStext As String
Op = File.OpenText(Application.StartupPath & "\pass.txt")
Pass = Op.ReadToEnd
Op.Close()
If cmdChange.Text = "Change Password" Then
If Encrypt(InputBox("Old Password:")) = Pass Then
Label1.Text = "New Password:"
txtPass.Text = ""
cmdChange.Text = "Change!"
cmdOK.Text = "Cancel"
txtPass.Focus()
Else
MsgBox("Wrong Password!")
Exit Sub
End If
Else
NOp = File.CreateText(Application.StartupPath & "\pass.txt")
'daripada ribet, mending replace pass.txt lama dengan yang baru
NOp.Write(Encrypt(txtPass.Text))
NOp.Flush()
NOp.Close()
MsgBox("Password has been changed!")
cmdChange.Text = "Change Password"
cmdOK.Text = "Login"
txtPass.Focus()
Label1.Text = "Password:"
End If
End Sub
Private Sub ckShow_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ckShow.CheckedChanged
If ckShow.Checked = True Then
txtPass.PasswordChar = "" 'tampilkan password
Else
txtPass.PasswordChar = "*" 'memberikan karakter "*" pada password
End If
End Sub
Private Function GenerateHash(ByVal SourceText As String) As String
Dim SourceTStext As String
'Create an encoding object to ensure the encoding standard for the source text
Dim Ue As New UnicodeEncoding()
'Retrieve a byte array based on the source text
Dim ByteSourceText() As Byte = Ue.GetBytes(SourceTStext)
'Instantiate an MD5 Provider object
Dim Md5 As New MD5CryptoServiceProvider()
'Compute the hash value from the source
Dim ByteHash() As Byte = Md5.ComputeHash(ByteSourceText)
'And convert it to String format for return
Return Convert.ToBase64String(ByteHash)
End Function
'Sub Encrypt(ByVal teks As String)
'Dim gxry As New Encryption.Hash(Encryption.Hash.Provider.MD5)
' Encrypt = gxry.Calculate(teks).ToHex
'End Sub
End Classtuh coding updatenya,,,
0 error, 7 warnings

tp knp wktu dijalanin error ea???

help me plissssss
![[Image: YRtWp.1.gif]](http://feeds.feedburner.com/blogspot/YRtWp.1.gif)




