Advertisement
Guest User

Form1

a guest
Feb 21st, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 8.04 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Text
  3. Imports System.Security.Cryptography
  4.  
  5. Public Class Form1
  6.  
  7.  
  8.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  9.         ListView2.GridLines = True
  10.         ListView2.FullRowSelect = True
  11.  
  12.     End Sub
  13.  
  14.     'Private Function encode(ByVal key As String) As TripleDES
  15.     '    Dim md5 As MD5 = New MD5CryptoServiceProvider
  16.     '    Dim des As TripleDES = New TripleDESCryptoServiceProvider
  17.     '    des.Key = md5.ComputeHash(Encoding.Unicode.GetBytes(key))
  18.     '    des.IV = New Byte(((des.BlockSize / 8)) - 1) {}
  19.     '    Return des
  20.     'End Function
  21.  
  22.     'Private Function encry(value As String, key As String) As Byte()
  23.     '    Dim des As TripleDES = encode(key)
  24.     '    Dim encr As ICryptoTransform = des.CreateEncryptor
  25.     '    Dim input() As Byte = Encoding.Unicode.GetBytes(value)
  26.     '    Return encr.TransformFinalBlock(input, 0, input.Length)
  27.     'End Function
  28.  
  29.     'Private Function decry(value As String, key As String) As String
  30.     '    Dim by() As Byte = Convert.FromBase64String(value)
  31.     '    Dim des As TripleDES = encode(key)
  32.     '    Dim cry As ICryptoTransform = des.CreateDecryptor
  33.     '    Dim output() As Byte = cry.TransformFinalBlock(by, 0, by.Length)
  34.     '    Return Encoding.Unicode.GetString(output)
  35.     'End Function
  36.  
  37.     Private Sub SaveBtn_Click(sender As Object, e As EventArgs) Handles SaveBtn.Click
  38.  
  39.  
  40.  
  41.         Dim account As String = ListView1.Items(0).SubItems(0).Text
  42.         Dim username As String = ListView1.Items(0).SubItems(1).Text
  43.         Dim pw As String = ListView1.Items(0).SubItems(2).Text
  44.  
  45.         Try
  46.             Dim path As String = "C:\Program Files\Passwort Manager" 'C:\Users\Praktikant.IEBL\AppData\Roaming\test.txt°
  47.             Dim File As StreamWriter
  48.             ' Create or overwrite the file.
  49.             Dim SFD As New SaveFileDialog()
  50.             SaveFileDialog1.Filter = "txt files (*.txt)|*.txt"
  51.             SaveFileDialog1.FilterIndex = 1
  52.             SaveFileDialog1.RestoreDirectory = True
  53.             If (SaveFileDialog1.ShowDialog() = DialogResult.OK) Then
  54.                 File = My.Computer.FileSystem.OpenTextFileWriter(SFD.FileName, True)
  55.                 File.WriteLine("Account:" & account & "Username:" & username & "Password:" & pw)
  56.                 File.Close()
  57.             End If
  58.         Catch ex As Exception
  59.             MsgBox(ex.Message)
  60.  
  61.         End Try
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.         'Dim AccDaten As String = account
  84.         'Dim key As String = "kuchen"
  85.  
  86.         'Dim hash As String = decry(AccDaten, key)
  87.         'MsgBox(hash)
  88.  
  89.  
  90.         'Dim strTextAcc As String = account
  91.         'Dim strTextUsername As String = username
  92.         'Dim strTextPw As String = pw
  93.         'Dim Salt As String = "Start1234"
  94.  
  95.  
  96.  
  97.  
  98.  
  99.         'Try
  100.         '    Dim path As String = "C:\Users\Praktikant.IEBL\Desktop\testss.txt" 'C:\Users\Praktikant.IEBL\AppData\Roaming\test.txt
  101.  
  102.         '    ' Create or overwrite the file.
  103.         '    Dim file As System.IO.StreamWriter
  104.         '    file = My.Computer.FileSystem.OpenTextFileWriter(path, True)
  105.         '    file.WriteLine(hashGsmt)
  106.         '    file.Close()
  107.         'Catch ex As Exception
  108.         '    MsgBox(ex.Message)
  109.         'End Try
  110.  
  111.     End Sub
  112.  
  113.     'Private Sub decry(v As String)
  114.     '    Throw New NotImplementedException()
  115.     'End Sub
  116.  
  117.     Public Sub eintragen(ByVal account As String, ByVal username As String, ByVal pw As String)
  118.         ListView2.Items.Add(New ListViewItem(New String() {account, username, pw}))
  119.  
  120.     End Sub
  121.  
  122.     Private Sub NewAcc_Click(sender As Object, e As EventArgs) Handles NewAcc.Click
  123.  
  124.         Form2.ShowDialog()
  125.     End Sub
  126.  
  127.     Private Sub LoadBTN_Click(sender As Object, e As EventArgs) Handles LoadBTN.Click
  128.  
  129.         FillListFromFile()
  130.  
  131.  
  132.     End Sub
  133.  
  134.  
  135.     Public Sub FillListFromFile()
  136.         Dim srReader As StreamReader
  137.         Dim bla As String
  138.         Dim Einzelteile() As String
  139.         Dim X As Integer = 0
  140.         Dim OFD As New OpenFileDialog
  141.         Try
  142.             srReader = New StreamReader(OFD.FileName)
  143.             Do Until srReader.EndOfStream               ' Bis Dateiende erreicht
  144.                 bla = srReader.ReadLine                 ' Eine Zeile lesen
  145.                 Einzelteile = bla.Split(":")
  146.                 ' In Einzelteile zerlegen
  147.  
  148.                 ListView1.Items.Add(Einzelteile(1))
  149.                 ListView1.Items(X).SubItems.Add(Einzelteile(3))
  150.                 ListView1.Items(X).SubItems.Add(Einzelteile(5))
  151.  
  152.                 X = X + 1
  153.             Loop
  154.  
  155.             srReader.Close()
  156.             srReader.Dispose()
  157.         Catch ex As Exception
  158.  
  159.  
  160.             'MessageBox.Show(ex.Message)
  161.         Finally
  162.             ListView1.OwnerDraw = False
  163.             ListView1.View = View.Details
  164.         End Try
  165.     End Sub
  166.  
  167.     'Public Sub FillListFromFile()
  168.  
  169.     '    Dim md5Hasher As New Security.Cryptography.MD5CryptoServiceProvider
  170.     '    Dim bytes2hex = Function(bytes() As Byte) String.Join("", Array.ConvertAll(bytes, Function(b) b.ToString("x2")))
  171.     '    Dim md5 = Function(s As String) bytes2hex(md5Hasher.ComputeHash(System.Text.Decoder.UTF8.GetBytes(s)))
  172.  
  173.  
  174.  
  175.     '    Dim hashAccName = md5(strTextAcc)
  176.     '    Dim hashUsername = md5(strTextUsername)
  177.     '    Dim hashPw = md5(strTextPw)
  178.     '    Dim SaltHash As String = md5(Salt)
  179.     '    Dim daten As String = hashAccName + "§/:\§" + hashUsername + "§/:\§" + hashPw
  180.  
  181.     '    'Dim hashGsmt = MD5(SaltHash & daten)
  182.     '    Dim srReader As StreamReader
  183.     '    'Dim bla As String
  184.     '    'Dim Einzelteile() As String
  185.     '    Dim X As Integer = 0
  186.  
  187.  
  188.     '    srReader = New StreamReader("C:\Users\Praktikant.IEBL\Desktop\testss.txt")
  189.     '    Do Until srReader.EndOfStream               ' Bis Dateiende erreicht
  190.     '        Dim GsmtHash As String = srReader.ReadLine                 ' Eine Zeile lesen
  191.     '        Dim AccNameHash = ""
  192.     '        Dim UsernameHash = ""
  193.     '        Dim PwHash = ""
  194.  
  195.  
  196.  
  197.  
  198.     '    Loop
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.     '    'Try
  207.     '    '    srReader = New StreamReader("C:\Users\Praktikant.IEBL\Desktop\testss.txt")
  208.     '    '    Do Until srReader.EndOfStream               ' Bis Dateiende erreicht
  209.     '    '        bla = srReader.ReadLine                 ' Eine Zeile lesen
  210.     '    '        Einzelteile = bla.Split("§/:\§")
  211.     '    '        ' In Einzelteile zerlegen
  212.  
  213.     '    '        ListView2.Items.Add(Einzelteile(1))
  214.     '    '        ListView2.Items(X).SubItems.Add(Einzelteile(3))
  215.     '    '        ListView2.Items(X).SubItems.Add(Einzelteile(5))
  216.  
  217.     '    '        X = X + 1
  218.     '    '    Loop
  219.  
  220.     '    '    srReader.Close()
  221.     '    '    srReader.Dispose()
  222.     '    'Catch ex As Exception
  223.  
  224.  
  225.     '    '    'MessageBox.Show(ex.Message)
  226.     '    'Finally
  227.     '    '    ListView2.OwnerDraw = False
  228.     '    '    ListView2.View = View.Details
  229.     '    End Try
  230.     'End Sub
  231.  
  232.     Private Sub ListView2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView2.SelectedIndexChanged
  233.  
  234.     End Sub
  235.  
  236.  
  237.  
  238.     Private Sub BearbeitenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BearbeitenToolStripMenuItem.Click
  239.         Me.Close()
  240.     End Sub
  241.  
  242.     Private Sub EintagLöschenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EintagLöschenToolStripMenuItem.Click
  243.         Dim account As String = Form2.TextBox1.Text
  244.         Dim username As String = Form2.TextBox2.Text
  245.         Dim Pw As String = Form2.TextBox3.Text
  246.  
  247.  
  248.         ListView2.Items.Remove(New ListViewItem(New String() {account, username, Pw}))
  249.     End Sub
  250.  
  251.     Private Sub EintragHinzufügenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EintragHinzufügenToolStripMenuItem.Click
  252.  
  253.  
  254.         Form2.Show()
  255.     End Sub
  256.  
  257.     Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
  258.  
  259.     End Sub
  260.  
  261.     Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
  262.  
  263.     End Sub
  264. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement