Results 1 to 2 of 2

Thread: VB Encrypting Tutorial

  1. #1
    New member
    Join Date
    Mar 2013
    Location
    USA
    Posts
    20
    Rep Power
    0

    VB Encrypting Tutorial

    VB.NET Encryption Tutorial
    Requirements >> .Net Framework 4.0+ & Windows XP+
    (<< Introduction >>)

    Okay so in this tutorial you will learn the following: How to create an entry level VB Encrypter; How to create a VB.NET Forms Application; How to customize your code. In this tutorial we will be working with Visual Studio 2012 - Enterprise Edition, but most features (if not all features) can be accomplished with Visual Studio 2008+.

    (<< Encryption >>)

    >> First you want to open up visual studio and create a new project. This will be a Windows Forms Application.

    >> Now that you have created this project you will see the form layout. You can manipulate this as you want, but you must have the following
    1) A Rich Text Box (RichTextBox1)
    2) A Button (Button1)
    3) Another Button (Button2)
    Change the text of Button1 to Encrypt and the text of Button2 to Decrypt

    >> Now you should have something like this



    >> Okay now double click the Encrypt button. you now have entered the code view.

    >> Enter the following into your code view
    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
         Encrypt(RichTextBox1.Text)
    End Sub


    >> Now that you have that add the following code below End Sub
    Code:
    Private Sub Encrypt(ByVal rtb As String)
    
    End Sub


    >> Now you should no longer have an error. The following steps will go inside your Private Sub Encrypt

    >> Enter an if statment to check if the rich text box is empty
    Code:
    If (rtb.Length > 0) Then
    'The Rich Text Box Has some text inside it
    Else
    'The Rich Text Box is empty
    End If


    >> Now We need to add the encryption inside it. change 12 to the number you want to subtract by

    Code:
                Dim x As Integer = 12 ' Change this to any number you want!          
                Dim chars = rtb.ToCharArray
                Dim out = ""
                For Each chara In chars
                    Dim y = Asc(chara)
                    Dim z = y - x
                    If out = "" Then
                        out = z
                    Else
                        out = out & "-" & z
                    End If
                Next
    
                RichTextBox1.Text = out


    >> You should now have code that looks something like this (The MsgBox I did not include because it is not needed)
    Code:
    Public Class Form1
    
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Encrypt(RichTextBox1.Text)
        End Sub
    
    
        Private Sub Encrypt(ByVal rtb As String)
            If (rtb.Length > 0) Then
                'The Rich Text Box Has some text inside it
                Dim x As Integer = 12 ' Change this to any number you want!
                Dim chars = rtb.ToCharArray
                Dim out = ""
                For Each chara In chars
                    Dim y = Asc(chara)
                    Dim z = y - x
                    If out = "" Then
                        out = z
                    Else
                        out = out & "-" & z
                    End If
                Next
                RichTextBox1.Text = out
            Else
                'The Rich Text Box is empty
                MsgBox("Please enter some text to encrypt!", MsgBoxStyle.Information)
            End If
        End Sub
    End Class


    >> Decryption >>

    >> Im Assuming you understand the basics so I will go faster and with less references
    >> Double click the decrypt button
    >> Enter inside that private sub
    Code:
    Decrypt(RichTextBox1.Text)
    >> Now add this below the End Sub
    Code:
    Private Sub Decrypt(ByVal Rtb As String)
            If Rtb.Length > 0 Then
                Dim x As Integer = 12 ' CHANGE THIS TO THE NUMBER YOU PUT ABOVE
                Dim words = Rtb.Split("-")
                Dim out = ""
                For Each word In words
                    Dim letter = Chr((Int(word) + x))
                    If out = "" Then
                        out = letter
                    Else
                        out = out & letter
                    End If
                Next
                RichTextBox1.Text = out
            Else
                MsgBox("Please Enter some code to decrypt!", MsgBoxStyle.Information)
            End If
        End Sub
    >> Change 12 to your number!


    Final code!
    ScreenShot sense skids need to learn to type


    Last edited by Lystic; 04-19-2013 at 07:59 PM.

  2. #2
    Senior Member
    Join Date
    Mar 2013
    Location
    Russia
    Posts
    240
    Rep Power
    5
    Hey man nice tutorial, but if you make the text smaller, will be good.

    The Best VPN!
    VVV Click Below VVV


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •