Encode and Decode - February 2001

Some years ago I wrote a routine to encode and decode a string. I have noted lots of requests in various news groups for such a routine. So a few months ago I made the code available on my web site. There have been a number of downloads - so I decided to make it an 'official' tip of the month.

2009/11/07 - I converted the Encode/Decode routines to support VB.Net VS2005. The source code is available with the November 2009 tip. Click here to view that tip.

Demo Program

I wrote a VB 6 demo program to show how to use the object. The demo:

Properties and Methods

EncodeDecode Perform the function.
sPassword String to be encoded/decoded.
bEncode If true then encode, else decode.
NewKey Return a new key. Contains all the lower case letters of the alphabet.

Sample Calling Code

Private Sub DoEncode()
' Encode the string
    Dim obj As New cEncodeDecode
    With obj
        .sPassword = Me.Text1(0).Text
        .bEncode = True
        .sNewKey = Me.Text1(2).Text
        Me.Text1(1).Text = .EncodeDecode
    End With
    Set obj = Nothing
End Sub
Private Sub DoDecode()
    Dim obj As New cEncodeDecode
    With obj
        .sPassword = Me.Text1(1).Text
        .bEncode = False
        .sNewKey = Me.Text1(2).Text
        Me.Text1(0).Text = .EncodeDecode
    End With
    Set obj = Nothing
End Sub
Private Sub DoNewKey()
    Dim obj As New cEncodeDecode
    With obj
        Me.Text1(2).Text = .NewKey
    End With
    Set obj = Nothing
End Sub

Include In Your Application

cEncodeDecode.cls Provides properties and functions needed
to encode and decode a string.

Very Low Level Security

The encoding routines contained in this class module provide very low level security. Do not use these routines for critical information. The code is provided 'as is' with no warranty. Use at your own risk.

Download VB 6 Source Code

Click here to download the VB 6 source code [6k]

Previous Tip   Tip Index    Next Tip

Home

Updated 2009/11/07