Raven Posted February 22, 2009 Report Posted February 22, 2009 Imports System.TextImports System.Text.RegularExpressionsPublic Class Form1 'Autor : Raven 'Contact : raven_200155@yahoo.com Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim md5 As String If CheckBox1.Checked = True Then md5 = getMD5Hash(TextBox1.Text) TextBox2.Text = (md5) lblstatus.Text = "Done!" End If If CheckBox2.Checked = True Then md5 = StringToHex(TextBox1.Text) TextBox2.Text = (md5) lblstatus.Text = "Done!" End If If CheckBox3.Checked = True Then md5 = Encode(TextBox1.Text) TextBox2.Text = (md5) lblstatus.Text = "Done!" End If If CheckBox4.Checked = True Then md5 = StrEncrypt(TextBox1.Text) TextBox2.Text = (md5) lblstatus.Text = "Done!" End If If CheckBox5.Checked = True Then md5 = MessageReversal(TextBox1.Text) TextBox2.Text = (md5) lblstatus.Text = "Done!" End If If CheckBox6.Checked = True Then md5 = getSHA1Hash(TextBox1.Text) TextBox2.Text = (md5) lblstatus.Text = "Done!" End If If CheckBox7.Checked = True Then md5 = ConvertToBinary(TextBox1.Text) TextBox2.Text = (md5) lblstatus.Text = "Done!" End If If CheckBox8.Checked = True Then md5 = rot13(TextBox1.Text) TextBox2.Text = (md5) lblstatus.Text = "Done!" End If If CheckBox9.Checked = True Then md5 = TextBox1.Text md5 = XOREncryption(md5, TextBox1.Text) TextBox2.Text = md5 lblstatus.Text = "Done!" End If If CheckBox10.Checked = True Then TextBox2.Text = TextBox1.Text End If End Sub Function getMD5Hash(ByVal strToHash As String) As String Dim md5Obj As New Security.Cryptography.MD5CryptoServiceProvider Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash) bytesToHash = md5Obj.ComputeHash(bytesToHash) Dim strResult As String = "" For Each b As Byte In bytesToHash strResult += b.ToString("x2") Next Return strResult End Function Public Function StringToHex(ByVal str As String) As String Dim ret As String For i As Integer = 0 To str.Length - 1 ret &= Asc(str.Substring(i, 1)).ToString("x").ToUpper & " " Next Return ret.Trim() End Function Function Encode(ByVal dec As String) As String Dim bt() As Byte ReDim bt(dec.Length) bt = System.Text.Encoding.ASCII.GetBytes(dec) Dim enc As String enc = System.Convert.ToBase64String(bt) Return enc End Function Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Me.Close() End Sub Private Function StrEncrypt(ByVal EnStr As String) As String Dim Key As String Key = "Abt$9>3ZyX 21~)**1_0d%1xOp0#?s!14k-L7`3s9cxPo1ilIj=-0DnmOpas#$%5854/*?>00021atanu???" Dim p1 As Integer Randomize() p1 = (Rnd() * 8) + 1 Dim p2 As Integer p2 = Len(EnStr) Dim RandSeed As Integer RandSeed = p1 Dim i As Integer Dim s1 As String = "" Dim ft As String ft = "" For i = 1 To 50 s1 = s1 & Chr(Asc(Rnd() * 255)) Next ft = Chr(p1) & Chr(p2) Dim iXor As Integer For i = 1 To Len(EnStr) iXor = Asc(Mid(Key, i + p1, 1)) Xor Asc(Mid(EnStr, i, 1)) ft = ft & Chr(iXor) Next For i = Len(ft) To 50 ft = ft & Chr(Rnd() * 255) Next StrEncrypt = ft End Function Function MessageReversal(ByVal StrDataIn As String) Dim StrOut As String StrOut = "" Dim I As Integer For I = Len(StrDataIn) To 1 Step -1 StrOut &= Mid(StrDataIn, I, 1) Next MessageReversal = StrOut End Function Function getSHA1Hash(ByVal strToHash As String) As String Dim sha1Obj As New Security.Cryptography.SHA1CryptoServiceProvider Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash) bytesToHash = sha1Obj.ComputeHash(bytesToHash) Dim strResult As String = "" For Each b As Byte In bytesToHash strResult += b.ToString("x2") Next Return strResult End Function Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click AboutBox1.Show() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim a As String If CheckBox15.Checked = True Then a = HexToString(TextBox2.Text) TextBox1.Text = a ElseIf CheckBox13.Checked = True Then a = Decode(TextBox2.Text) TextBox1.Text = a ElseIf CheckBox14.Checked = True Then a = ConvertToAscii(TextBox2.Text) TextBox1.Text = a ElseIf CheckBox12.Checked = True Then TextBox1.Text = TextBox2.Text End If End Sub Public Function ConvertToBinary(ByVal str As String) As String Dim converted As New StringBuilder For Each b As Byte In ASCIIEncoding.ASCII.GetBytes(str) converted.Append(Convert.ToString(b, 2).PadLeft(8, "0")) Next Return converted.ToString() End Function Function rot13(ByVal rot13text) Dim k, j, rot13text_rotated As String rot13text_rotated = "" For i = 1 To Len(rot13text) j = Mid(rot13text, i, 1) k = Asc(j) If k >= 97 And k <= 109 Then k = k + 13 ElseIf k >= 110 And k <= 122 Then k = k - 13 ElseIf k >= 65 And k <= 77 Then k = k + 13 ElseIf k >= 78 And k <= 90 Then k = k - 13 End If rot13text_rotated = rot13text_rotated & Chr(k) Next rot13 = rot13text_rotated End Function Public Function XOREncryption(ByVal CodeKey As String, ByVal DataIn As String) As String Dim lonDataPtr As Long Dim strDataOut As String Dim temp As Integer Dim tempstring As String Dim intXOrValue1 As Integer Dim intXOrValue2 As Integer For lonDataPtr = 1 To Len(DataIn) intXOrValue1 = Asc(Mid$(DataIn, lonDataPtr, 1)) intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1)) temp = (intXOrValue1 Xor intXOrValue2) tempstring = Hex(temp) If Len(tempstring) = 1 Then tempstring = "0" & tempstring strDataOut = strDataOut + tempstring Next lonDataPtr XOREncryption = strDataOut End Function Function Decode(ByVal enc As String) As String Dim bt() As Byte bt = System.Convert.FromBase64String(enc) Dim dec As String dec = System.Text.Encoding.ASCII.GetString(bt) Return dec End Function Public Function HexToString(ByVal HexToStr As String) As String Dim strTemp As String Dim strReturn As String Dim I As Long For I = 1 To Len(HexToStr) Step 3 strTemp = Chr(Val("&H" & Mid(HexToStr, I, 2))) strReturn = strReturn & strTemp Next I HexToString = strReturn End Function Public Function ConvertToAscii(ByVal str As String) As String Dim chars As String = Regex.Replace(str, "[^01]", "") Dim arr((chars.Length / 8) - 1) As Byte For i As Integer = 0 To arr.Length - 1 arr(i) = Convert.ToByte(chars.Substring(i * 8, 8), 2) Next Return ASCIIEncoding.ASCII.GetString(arr) End Function Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Me.SaveFileDialog1.ShowDialog() Me.TextBox3.Text = Me.SaveFileDialog1.FileName End Sub Function EncodeByte(ByVal bt() As Byte) As String Dim enc As String enc = System.Convert.ToBase64String(bt) Return enc End Function Function DecodeToByte(ByVal enc As String) As Byte() Dim bt() As Byte bt = System.Convert.FromBase64String(enc) Return bt End Function Sub DecodeFile(ByVal srcFile As String, ByVal destFile As String) Dim src As String Dim sr As New IO.StreamReader(srcFile) src = sr.ReadToEnd sr.Close() Dim bt64 As Byte() = DecodeToByte(src) If IO.File.Exists(destFile) Then IO.File.Delete(destFile) End If Dim sw As New IO.FileStream(destFile, IO.FileMode.CreateNew) sw.Write(bt64, 0, bt64.Length) sw.Close() End Sub Sub EncodeFile(ByVal srcFile As String, ByVal destfile As String) Dim srcBT As Byte() Dim dest As String Dim sr As New IO.FileStream(srcFile, IO.FileMode.Open) ReDim srcBT(sr.Length) sr.Read(srcBT, 0, sr.Length) sr.Close() dest = EncodeByte(srcBT) If IO.File.Exists(destfile) Then IO.File.Delete(destfile) End If Dim sw As New IO.StreamWriter(destfile, False) sw.Write(dest) sw.Close() End Sub Private Sub butDecode2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butDecode2.Click Try If Me.TextBox3.Text = Nothing Or Me.TextBox4.Text = Nothing Then MsgBox("Please select source and destination files!") Exit Sub End If Me.DecodeFile(Me.TextBox4.Text, Me.TextBox3.Text) MsgBox("Conversion complete!") Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Private Sub butEndcode2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butEndcode2.Click Try If Me.TextBox3.Text = Nothing Or Me.TextBox4.Text = Nothing Then MsgBox("Please select source and destination files!") Exit Sub End If Me.EncodeFile(Me.TextBox3.Text, Me.TextBox4.Text) MsgBox("Conversion complete!") Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.SaveFileDialog1.ShowDialog() Me.TextBox4.Text = Me.SaveFileDialog1.FileName End SubEnd ClassScreenshot aici:http://i40.tinypic.com/2prsd1u.jpgDownload: .exehttp://rapidshare.com/files/201615784/Encryption_Center.rar.htmlPastebin :http://pastebin.com/m5e6c431dLanguage : VB.NET Autor : Eu Bafta
indetect49 Posted November 6, 2014 Report Posted November 6, 2014 thank's man for this great code can you take it in project thank's