Now Playing Tracks

Text Encryption

Here is a simple code to encrypt text. I guess I could post the code here, since it’s not too long. The code itself is simple and easy to apply to a button, a timer, or anything you want.

Below is the code:

—————————————————————-

    Dim vEncrypt As String = “”

    Dim vLetter As Char

    Dim i, charsInFile As Short

            Try

                charsInFile = TextBox1.Text.Length

                For i = 0 To charsInFile - 1

                    vLetter = TextBox1.Text.Substring(i, 1)

                    vEncrypt = vEncrypt & Chr(Asc(vLetter) + 1)

                Next

                Label1.Text = “Encryption done: “

                TextBox1.Text = vEncrypt

            Catch ex As Exception

                MsgBox(“An error occured: ” & vbCrLf & ex.Message)

            End Try

——————————————————————————————-

I didn’t put any comments yet (will do so later on), though I did it differently for my own project.

I’ll post it later on with the decryption code too :)

To Tumblr, Love Pixel Union