Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Text
- Imports System.Security.Cryptography
- Public Class Form1
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- ListView2.GridLines = True
- ListView2.FullRowSelect = True
- End Sub
- 'Private Function encode(ByVal key As String) As TripleDES
- ' Dim md5 As MD5 = New MD5CryptoServiceProvider
- ' Dim des As TripleDES = New TripleDESCryptoServiceProvider
- ' des.Key = md5.ComputeHash(Encoding.Unicode.GetBytes(key))
- ' des.IV = New Byte(((des.BlockSize / 8)) - 1) {}
- ' Return des
- 'End Function
- 'Private Function encry(value As String, key As String) As Byte()
- ' Dim des As TripleDES = encode(key)
- ' Dim encr As ICryptoTransform = des.CreateEncryptor
- ' Dim input() As Byte = Encoding.Unicode.GetBytes(value)
- ' Return encr.TransformFinalBlock(input, 0, input.Length)
- 'End Function
- 'Private Function decry(value As String, key As String) As String
- ' Dim by() As Byte = Convert.FromBase64String(value)
- ' Dim des As TripleDES = encode(key)
- ' Dim cry As ICryptoTransform = des.CreateDecryptor
- ' Dim output() As Byte = cry.TransformFinalBlock(by, 0, by.Length)
- ' Return Encoding.Unicode.GetString(output)
- 'End Function
- Private Sub SaveBtn_Click(sender As Object, e As EventArgs) Handles SaveBtn.Click
- Dim account As String = ListView1.Items(0).SubItems(0).Text
- Dim username As String = ListView1.Items(0).SubItems(1).Text
- Dim pw As String = ListView1.Items(0).SubItems(2).Text
- Try
- Dim path As String = "C:\Program Files\Passwort Manager" 'C:\Users\Praktikant.IEBL\AppData\Roaming\test.txt°
- Dim File As StreamWriter
- ' Create or overwrite the file.
- Dim SFD As New SaveFileDialog()
- SaveFileDialog1.Filter = "txt files (*.txt)|*.txt"
- SaveFileDialog1.FilterIndex = 1
- SaveFileDialog1.RestoreDirectory = True
- If (SaveFileDialog1.ShowDialog() = DialogResult.OK) Then
- File = My.Computer.FileSystem.OpenTextFileWriter(SFD.FileName, True)
- File.WriteLine("Account:" & account & "Username:" & username & "Password:" & pw)
- File.Close()
- End If
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- 'Dim AccDaten As String = account
- 'Dim key As String = "kuchen"
- 'Dim hash As String = decry(AccDaten, key)
- 'MsgBox(hash)
- 'Dim strTextAcc As String = account
- 'Dim strTextUsername As String = username
- 'Dim strTextPw As String = pw
- 'Dim Salt As String = "Start1234"
- 'Try
- ' Dim path As String = "C:\Users\Praktikant.IEBL\Desktop\testss.txt" 'C:\Users\Praktikant.IEBL\AppData\Roaming\test.txt
- ' ' Create or overwrite the file.
- ' Dim file As System.IO.StreamWriter
- ' file = My.Computer.FileSystem.OpenTextFileWriter(path, True)
- ' file.WriteLine(hashGsmt)
- ' file.Close()
- 'Catch ex As Exception
- ' MsgBox(ex.Message)
- 'End Try
- End Sub
- 'Private Sub decry(v As String)
- ' Throw New NotImplementedException()
- 'End Sub
- Public Sub eintragen(ByVal account As String, ByVal username As String, ByVal pw As String)
- ListView2.Items.Add(New ListViewItem(New String() {account, username, pw}))
- End Sub
- Private Sub NewAcc_Click(sender As Object, e As EventArgs) Handles NewAcc.Click
- Form2.ShowDialog()
- End Sub
- Private Sub LoadBTN_Click(sender As Object, e As EventArgs) Handles LoadBTN.Click
- FillListFromFile()
- End Sub
- Public Sub FillListFromFile()
- Dim srReader As StreamReader
- Dim bla As String
- Dim Einzelteile() As String
- Dim X As Integer = 0
- Dim OFD As New OpenFileDialog
- Try
- srReader = New StreamReader(OFD.FileName)
- Do Until srReader.EndOfStream ' Bis Dateiende erreicht
- bla = srReader.ReadLine ' Eine Zeile lesen
- Einzelteile = bla.Split(":")
- ' In Einzelteile zerlegen
- ListView1.Items.Add(Einzelteile(1))
- ListView1.Items(X).SubItems.Add(Einzelteile(3))
- ListView1.Items(X).SubItems.Add(Einzelteile(5))
- X = X + 1
- Loop
- srReader.Close()
- srReader.Dispose()
- Catch ex As Exception
- 'MessageBox.Show(ex.Message)
- Finally
- ListView1.OwnerDraw = False
- ListView1.View = View.Details
- End Try
- End Sub
- 'Public Sub FillListFromFile()
- ' Dim md5Hasher As New Security.Cryptography.MD5CryptoServiceProvider
- ' Dim bytes2hex = Function(bytes() As Byte) String.Join("", Array.ConvertAll(bytes, Function(b) b.ToString("x2")))
- ' Dim md5 = Function(s As String) bytes2hex(md5Hasher.ComputeHash(System.Text.Decoder.UTF8.GetBytes(s)))
- ' Dim hashAccName = md5(strTextAcc)
- ' Dim hashUsername = md5(strTextUsername)
- ' Dim hashPw = md5(strTextPw)
- ' Dim SaltHash As String = md5(Salt)
- ' Dim daten As String = hashAccName + "§/:\§" + hashUsername + "§/:\§" + hashPw
- ' 'Dim hashGsmt = MD5(SaltHash & daten)
- ' Dim srReader As StreamReader
- ' 'Dim bla As String
- ' 'Dim Einzelteile() As String
- ' Dim X As Integer = 0
- ' srReader = New StreamReader("C:\Users\Praktikant.IEBL\Desktop\testss.txt")
- ' Do Until srReader.EndOfStream ' Bis Dateiende erreicht
- ' Dim GsmtHash As String = srReader.ReadLine ' Eine Zeile lesen
- ' Dim AccNameHash = ""
- ' Dim UsernameHash = ""
- ' Dim PwHash = ""
- ' Loop
- ' 'Try
- ' ' srReader = New StreamReader("C:\Users\Praktikant.IEBL\Desktop\testss.txt")
- ' ' Do Until srReader.EndOfStream ' Bis Dateiende erreicht
- ' ' bla = srReader.ReadLine ' Eine Zeile lesen
- ' ' Einzelteile = bla.Split("§/:\§")
- ' ' ' In Einzelteile zerlegen
- ' ' ListView2.Items.Add(Einzelteile(1))
- ' ' ListView2.Items(X).SubItems.Add(Einzelteile(3))
- ' ' ListView2.Items(X).SubItems.Add(Einzelteile(5))
- ' ' X = X + 1
- ' ' Loop
- ' ' srReader.Close()
- ' ' srReader.Dispose()
- ' 'Catch ex As Exception
- ' ' 'MessageBox.Show(ex.Message)
- ' 'Finally
- ' ' ListView2.OwnerDraw = False
- ' ' ListView2.View = View.Details
- ' End Try
- 'End Sub
- Private Sub ListView2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView2.SelectedIndexChanged
- End Sub
- Private Sub BearbeitenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BearbeitenToolStripMenuItem.Click
- Me.Close()
- End Sub
- Private Sub EintagLöschenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EintagLöschenToolStripMenuItem.Click
- Dim account As String = Form2.TextBox1.Text
- Dim username As String = Form2.TextBox2.Text
- Dim Pw As String = Form2.TextBox3.Text
- ListView2.Items.Remove(New ListViewItem(New String() {account, username, Pw}))
- End Sub
- Private Sub EintragHinzufügenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EintragHinzufügenToolStripMenuItem.Click
- Form2.Show()
- End Sub
- Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
- End Sub
- Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement