Library code snippets

Simple Encryption

Simple Encryption

Make four text boxes, and two controls. Name the text boxes txtCTC, txtCipher, txtCTDC, and txtDCC. Name the command buttons cmdCipher, and cmdDecipher. Input this code. When you enter a single letter in txtCTC and press cmdCipher, it comes out as a ciphered letter. When you put the ciphered letter in txtCTDC, it comes out as the original letter. This only works with one letter at a time.

Dim Num1 As String
Dim Num2 As String


Private Sub cmdCipher_Click()
Num1 = Asc(txtCTC.Text) 'Converts the letter to a ANSI number
Num1 = Num1 + 3 'Adds three to the ANSI number
Num2 = Chr$(Num1)
'Converts the ANSI number back to a letter
txtCipher.Text = txtCipher.Text + Num2 'Adds the ciphered letter to the end of whatever was previously in the textbox
End Sub

Private Sub cmdDecipher_Click()
Num1 = Asc(txtCTDC.Text) 'Converts the ciphered letter to a ANSI number
Num1 = Num1 - 3 'Subtracts three from the ANSI number
Num2 = Chr$(Num1) 'Converts the ANSI number back to a letter
txtDCC.Text = txtDCC.Text + Num2 'Adds the deciphered letter to the end of whatever was previously in the textbox
End Sub

'Credit goes to Daniel Thompson, A.K.A. HLF926

Comments

  1. 18 May 2005 at 21:16

    I made an encrypter once, named SafeCrypt, it's on my website, click here to download


    i'll post the source for the encryption when i find the time and don't forget it.

  2. 19 Feb 2004 at 11:39
    This was a great article..


    Now does anyone have any suggestions on how to make this encription method a litle more complex..??
  3. 05 Nov 2003 at 07:39
    Brilliant, simple yet effective and allows you to create your own method of cypher using this as a backbone
  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Simple Encryption.

Leave a comment

Sign in or Join us (it's free).

 DT

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

We'd love to hear what you think! Submit ideas or give us feedback