Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Security.Cryptography
- Imports System.IO
- Imports System.Text
- Public Class Form1
- Dim operand1 As Double = 0
- Dim operand2 As Double = 0
- Dim op As String = Nothing
- Dim newoperand As Boolean = True
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Randomize()
- Dim a, b, c, d, f, g, h, i, j, k, l, Phrase As Integer
- Dim t As New Color
- Dim li As List(Of String) = New List(Of String)
- li.Add("Md5 Sum's and More!")
- li.Add("Md5 Sum's arn't they Great!")
- li.Add("It Has a Calculator!")
- li.Add("It Knows Binary!!")
- li.Add("It Does Hex")
- li.Add("It Does The Math For You ;)")
- li.Add("Are The Files The Same?? :D")
- li.Add("00110011001100000011001100110000001100110011000100110011001100010011001100000110011")
- Me.Text = li.Item(Int(Rnd() * (li.Count - 1)))
- t = Color.Transparent
- a = Int(Rnd() * 255)
- b = Int(Rnd() * 255)
- c = Int(Rnd() * 255)
- d = Int(Rnd() * 255)
- f = Int(Rnd() * 255)
- g = Int(Rnd() * 255)
- h = Int(Rnd() * 255)
- i = Int(Rnd() * 255)
- j = Int(Rnd() * 255)
- k = Int(Rnd() * 255)
- l = Int(Rnd() * 255)
- tabFile.BackColor = Color.FromArgb(a, b, c, 0)
- tabText.BackColor = Color.FromArgb(h, d, g, 0)
- tabCheck.BackColor = Color.FromArgb(j, k, h, 0)
- tabTexttoBinary.BackColor = Color.FromArgb(i, c, k, 0)
- tabTexttoHex.BackColor = Color.FromArgb(l, h, a, 0)
- tabCount.BackColor = Color.FromArgb(b, c, i, 0)
- tabCal.BackColor = Color.FromArgb(l, h, j, 0)
- tabAESDecriptText.BackColor = Color.FromArgb(i, g, h, 0)
- tabAESEncriptText.BackColor = Color.FromArgb(k, j, j, 0)
- MenuStrip1.BackColor = Color.FromArgb(b, k, f, 0)
- btnFile.BackColor = Color.FromArgb(f, g, b, 0)
- btnText.BackColor = Color.FromArgb(b, l, c, 0)
- btnCheck.BackColor = Color.FromArgb(k, i, l, 0)
- btnBinary.BackColor = Color.FromArgb(g, j, b, 0)
- btnHex.BackColor = Color.FromArgb(c, a, d, 0)
- btnCount.BackColor = Color.FromArgb(a, g, k, 0)
- btnDecrypt.BackColor = Color.FromArgb(l, f, k, 0)
- btnEncrypt.BackColor = Color.FromArgb(b, d, d, 0)
- btn0.Text = "0"
- btn1.Text = "1"
- btn2.Text = "2"
- btn3.Text = "3"
- btn4.Text = "4"
- btn5.Text = "5"
- btn6.Text = "6"
- btn7.Text = "7"
- btn8.Text = "8"
- btn9.Text = "9"
- btnDivide.Text = "/"
- btnDot.Text = "."
- btnEqual.Text = "="
- btnTimes.Text = "*"
- btnClear.Text = "Clear"
- btnPlus.Text = "+"
- btnOff.Text = "Off"
- btnMinus.Text = "-"
- btn0.Tag = "0"
- btn1.Tag = "1"
- btn2.Tag = "2"
- btn3.Tag = "3"
- btn4.Tag = "4"
- btn5.Tag = "5"
- btn6.Tag = "6"
- btn7.Tag = "7"
- btn8.Tag = "8"
- btn9.Tag = "9"
- btnDivide.Tag = "/"
- btnDot.Tag = "."
- btnEqual.Tag = "="
- btnTimes.Tag = "*"
- btnPlus.Tag = "+"
- btnMinus.Tag = "-"
- txtText.BackColor = Color.SteelBlue
- txtBinaryOutput.BackColor = Color.SteelBlue
- txtHexOutput.BackColor = Color.SteelBlue
- txtTextB.BackColor = Color.SteelBlue
- txtTextH.BackColor = Color.SteelBlue
- txtMd5.BackColor = Color.SteelBlue
- txtOutput.BackColor = Color.SteelBlue
- txtInput.BackColor = Color.SteelBlue
- txtDisplay.BackColor = Color.SteelBlue
- txtDecryptOutput.BackColor = Color.SteelBlue
- txtEncriptedOutput.BackColor = Color.SteelBlue
- txtToDecrypt.BackColor = Color.SteelBlue
- txtToEncrypt.BackColor = Color.SteelBlue
- txtTextC.BackColor = Color.SteelBlue
- Label1.BackColor = t
- Label2.BackColor = t
- Label3.BackColor = t
- Label4.BackColor = t
- Label5.BackColor = t
- Label6.BackColor = t
- lblResualt.BackColor = t
- lblTotF.BackColor = t
- Label7.BackColor = t
- Label8.BackColor = t
- lblCharCount.BackColor = t
- Label11.BackColor = t
- Label10.BackColor = t
- Label9.BackColor = t
- lblResualt.Text = Nothing
- lblTotF.Text = Nothing
- lblCharCount.Text = Nothing
- Me.BackColor = Color.Thistle
- End Sub
- Private Sub btnFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFile.Click
- OpenFileDialog1.ShowDialog()
- txtInput.Text = OpenFileDialog1.FileName()
- txtOutput.Text = MD5CalcFile(OpenFileDialog1.FileName())
- End Sub
- Private Sub btnText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnText.Click
- txtMd5Text.Text = StringToMD5(txtText.Text)
- End Sub
- Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
- OpenFileDialog1.ShowDialog()
- lblResualt.Text = MD5CalcFile(OpenFileDialog1.FileName())
- If lblResualt.Text = txtMd5.Text Then
- lblTotF.Text = "True"
- Else
- lblTotF.Text = "False, Md5 Not The Same"
- End If
- End Sub
- Private Sub btnBinary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBinary.Click
- txtBinaryOutput.Text = ConvertToBinary(txtTextB.Text)
- End Sub
- Private Sub btnHex_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHex.Click
- Dim str As String
- Dim byteArray() As Byte
- Dim hexNumbers As System.Text.StringBuilder = New System.Text.StringBuilder
- str = txtTextH.Text
- byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
- For i As Integer = 0 To byteArray.Length - 1
- hexNumbers.Append(byteArray(i).ToString("x"))
- Next
- txtHexOutput.Text = hexNumbers.ToString()
- End Sub
- Private Sub btnCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCount.Click
- Dim a As String
- a = txtTextC.Text
- a = a.Trim
- a = a.Length
- lblCharCount.Text = a
- 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
- Private Function StringToMD5(ByVal Content As String) As String
- Dim M5 As New Security.Cryptography.MD5CryptoServiceProvider
- Dim ByteString() As Byte = System.Text.Encoding.ASCII.GetBytes(Content)
- ByteString = M5.ComputeHash(ByteString)
- Dim FinalString As String = Nothing
- For Each bt As Byte In ByteString
- FinalString &= bt.ToString("x2")
- Next
- Return FinalString
- End Function
- Public Function MD5CalcFile(ByVal filepath As String) As String
- Using reader As New System.IO.FileStream(filepath, IO.FileMode.Open, IO.FileAccess.Read)
- Using md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim hash() As Byte = md5.ComputeHash(reader)
- Return ByteArrayToString(hash)
- End Using
- End Using
- End Function
- Private Function ByteArrayToString(ByVal arrInput() As Byte) As String
- Dim sb As New System.Text.StringBuilder(arrInput.Length * 2)
- For i As Integer = 0 To arrInput.Length - 1
- sb.Append(arrInput(i).ToString("X2"))
- Next
- Return sb.ToString().ToLower
- End Function
- Private Sub btnOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOff.Click
- Application.Exit()
- End Sub
- Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDot.Click, btn0.Click, btn1.Click, btn2.Click, btn3.Click, btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click
- Dim btnNumberClicked As Button = sender
- If newoperand Then
- txtDisplay.Text = btnNumberClicked.Tag
- newoperand = False
- Else
- txtDisplay.Text &= btnNumberClicked.Tag
- End If
- End Sub
- Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
- txtDisplay.Text = "0"
- operand1 = 0
- operand2 = 0
- newoperand = True
- op = Nothing
- End Sub
- Private Sub btnOperator_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click, btnPlus.Click, btnMinus.Click, btnTimes.Click, btnEqual.Click
- Dim operatorSelected As Button = sender
- If (operand1 = 0 And op = Nothing) Or op = "=" Then
- operand1 = Val(txtDisplay.Text)
- Else
- operand2 = Val(txtDisplay.Text)
- operand1 = Calcualte(operand1, operand2, op)
- Me.txtDisplay.Text = operand1
- End If
- op = operatorSelected.Tag
- newoperand = True
- End Sub
- Function Calcualte(ByVal firstOperand As Double, ByVal secondOperand As Double, ByVal op As String) As Double
- Select Case op
- Case "+"
- Return (firstOperand + secondOperand)
- Case "-"
- Return (firstOperand - secondOperand)
- Case "x"
- Return (firstOperand * secondOperand)
- Case "/"
- Return (firstOperand / secondOperand)
- End Select
- End Function
- Private Sub StringsToolSripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StringsToolStripMenuItem.Click
- Form2.Show()
- End Sub
- Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- Application.Exit()
- End Sub
- Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
- Dim AES As New System.Security.Cryptography.RijndaelManaged
- Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim encrypted As String = ""
- Try
- Dim hash(31) As Byte
- Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 16)
- AES.Key = hash
- AES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
- Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
- encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return encrypted
- Catch ex As Exception
- End Try
- End Function
- Public Function AES_Decrypt(ByVal input As String, ByVal pass As String) As String
- Dim AES As New System.Security.Cryptography.RijndaelManaged
- Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim decrypted As String = ""
- Try
- Dim hash(31) As Byte
- Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 16)
- AES.Key = hash
- AES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
- Dim Buffer As Byte() = Convert.FromBase64String(input)
- decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return decrypted
- Catch ex As Exception
- End Try
- End Function
- Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
- Dim Pass As String
- Pass = InputBox("Enter The PassWord To Encrypt With:")
- If Pass = Nothing Then
- MessageBox.Show("Y U NO ENTER A PASSWORD?")
- Else
- txtEncriptedOutput.Text = AES_Encrypt(txtToEncrypt.Text, Pass)
- End If
- End Sub
- Private Sub btnDecrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecrypt.Click
- Dim Pass As String
- Pass = InputBox("Enter The PassWord To Encrypt With:")
- If Pass = Nothing Then
- MessageBox.Show("Y U NO ENTER A PASSWORD?")
- Else
- txtDecryptOutput.Text = AES_Decrypt(txtToDecrypt.Text, Pass)
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement