1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Public Class Form11
Private Sub BcButtonOld1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BcButtonOld1.Click
Try
Dim sfd As New SaveFileDialog With {.Filter = ".exe|*.exe", .ShowHelp = True}
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim encryption_key As String = random_key(16)
Dim source As String = My.Resources.source
Dim vars As String() = {"%1%", "%2%", "%4%", "%5%"}
For i As Integer = 0 To vars.Length - 1
source = source.Replace(vars(i), random_key(15))
Next
Dim input As Byte() = encrypt(IO.File.ReadAllBytes(TextBox1.Text), encryption_key) 'Read & Encrypt to crypt
source = source.Replace("%3%", Format(input))
source = source.Replace("%6%", random_key(5))
source = source.Replace("%7%", encryption_key)
iCompiler.GenerateExecutable(sfd.FileName, source, "")
MessageBox.Show("File encrypted successfully.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
End Try
End Sub
Public Function random_key(ByVal lenght As Integer) As String
Randomize()
Dim s As New System.Text.StringBuilder("")
Dim b() As Char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".ToCharArray()
For i As Integer = 1 To lenght
Randomize()
Dim z As Integer = Int(((b.Length - 2) - 0 + 1) * Rnd()) + 1
s.Append(b(z))
Next
Return s.ToString
End Function
Public Function encrypt(ByVal message As Byte(), ByVal password As String) As Byte()
Dim passarr As Byte() = System.Text.Encoding.UTF8.GetBytes(password)
Randomize()
Dim rand As Integer = Int((255 - 0 + 1) * Rnd()) + 1
Dim outarr(message.Length) As Byte
Dim u As Integer
For i As Integer = 0 To message.Length - 1
outarr(i) += (message(i) Xor passarr(u)) Xor rand
If u = password.Length - 1 Then u = 0 Else u = u + 1
Next
outarr(message.Length) = 112 Xor rand
Return outarr
End Function
End Class |
Partager