BP Forums
Pleese help Brandonio21 - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: Pleese help Brandonio21 (/showthread.php?tid=335)



Pleese help Brandonio21 - RushingRussian - 04-01-2011

i made an encrypter function which encrypts text by replacing the letters with some random binary numbers i want to make something more advanced which is included in vb.
I looked on youtube but didnt find anything advanced but easy PLZ HELP. <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: --> <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: --> <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: --> <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->
Code:
Public Function encrypt() As String
        Dim letat, letspace, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String
        Dim outcome As String
        letat = "@"
        letspace = " "
        a = "a"
        b = "b"
        c = "c"
        d = "d"
        e = "e"
        f = "f"
        g = "g"
        h = "h"
        i = "i"
        j = "j"
        k = "k"
        l = "l"
        m = "m"
        n = "n"
        o = "o"
        p = "p"
        q = "q"
        r = "r"
        s = "s"
        t = "t"
        u = "u"
        v = "v"
        w = "w"
        x = "x"
        y = "y"
        z = "z"

        outcome = TextBox1.Text
        outcome = Replace(outcome, letat, "0100101101100110000010011010000")
        outcome = Replace(outcome, letspace, "10111011010110010100111110011011010101100100000110010100101100010110000100100000101011101010001010")
        outcome = Replace(outcome, a, "1110000001111000111001110001010101011110110010010000100100010110111011010110000111101110100")
        outcome = Replace(outcome, b, "1101110010011001110001100110110001001011000101010100000100001111110101111110111000111000010")
        outcome = Replace(outcome, c, "00011000100100111001100001111010001010000001011100000101110000110010111110010101010110111110011100100")
        outcome = Replace(outcome, d, "0000011000010010")
        outcome = Replace(outcome, e, "1110110001101110100111111010001101000011100100101011101110100000101001001010011101000100101010100100")
        outcome = Replace(outcome, f, "1001001010011100")
        outcome = Replace(outcome, g, "1111011011100000")
        outcome = Replace(outcome, h, "0100000001101110")
        outcome = Replace(outcome, i, "0101110000000111")
        outcome = Replace(outcome, j, "1001000111010000")
        outcome = Replace(outcome, k, "0010100011010000")
        outcome = Replace(outcome, l, "1000000001111010")
        outcome = Replace(outcome, m, "1010110000100011")
        outcome = Replace(outcome, n, "1011111000100111")
        outcome = Replace(outcome, o, "0000000000000000")
        outcome = Replace(outcome, p, "0011110101001000")
        outcome = Replace(outcome, q, "0001110011011011")
        outcome = Replace(outcome, r, "0000111010001010")
        outcome = Replace(outcome, s, "1012020201102")
        outcome = Replace(outcome, t, "11101010001110110110101011000101010100000001110110101011110101111100100101101000001011000101001")
        outcome = Replace(outcome, u, "1110101100001011")
        outcome = Replace(outcome, v, "1011111001110000")
        outcome = Replace(outcome, w, "1000110010010001")
        outcome = Replace(outcome, x, "1001111010000011")
        outcome = Replace(outcome, y, "0101100001010110")
        outcome = Replace(outcome, z, "1011111010010001")

        encrypt = outcome
        Return encrypt
    End Function



Re: Pleese help Brandonio21 - xolara - 04-01-2011

I have posted a code here on bpforums

It encrypts the text you input with a password of your choice

1 Form
2 Textboxes 1 of them is multilined and the other is for password
2 buttons Encrypt and Decrypt

Code:
Public Class Form1
        Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
        Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
                DES.Mode = Security.Cryptography.CipherMode.ECB
                Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
                Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox2.Text)
                TextBox2.Text = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
            Catch ex As Exception
                MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub

        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Try
                DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
                DES.Mode = Security.Cryptography.CipherMode.ECB
                Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
                Dim Buffer As Byte() = Convert.FromBase64String(TextBox2.Text)
                TextBox2.Text = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
            Catch ex As Exception
                MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub
    End Class



Re: Pleese help Brandonio21 - brandonio21 - 04-01-2011

Yes, Xolara's code should do the job just right. Try it out!