# Algorithum Encryption and Decryption

This code will take text, and encrypt it in Algorithum Encryption. What it does is randomly create 4 keys, each one 1 char long. No password needed to encrypt the text, it creates its own and stores it within the encrypted text. Virtualy impossible to crack because the output encryption is rarely the same. For example, a string that says "test" will be 8 charachters long, and almost never the same. Or a string that says "testing" will be 11 charachters long. The key to encrypt and decrypt is stored at the beginning and the end of the output making it almost impossible to crack.

Original Author: Jeffrey C. Tatum

### Assumptions

To see how this code works, create 3 text box's. Text1, Text2, and Text3.
In Text1_Change, put:
text2 = TEncrypt(text1)
In Text2_Change, put:
text3 = TDecrypt(text2)
Put nothing in Text3_Change.
What this will show you is the text you type in Text1, will get encrypted into Text2. It will then Decrypt itself and show you in Text3.

### Code

`Function TEncrypt (iString)On Error GoTo uhohQ = ""a = randomnumber(9) + 32b = randomnumber(9) + 32c = randomnumber(9) + 32d = randomnumber(9) + 32Q = Chr(a) & Chr(c) & Chr(b)e = 1For x = 1 To Len(iString)f = Mid(iString, x, 1)    If e = 1 Then Q = Q & Chr(Asc(f) + a)  If e = 2 Then Q = Q & Chr(Asc(f) + c)  If e = 3 Then Q = Q & Chr(Asc(f) + b)  If e = 4 Then Q = Q & Chr(Asc(f) + d)e = e + 1If e > 4 Then e = 1Next xQ = Q & Chr(d)TEncrypt = QExit Functionuhoh:TEncrypt = "Error: Invalid text to Encrypt"Exit FunctionEnd FunctionFunction TDecrypt (iString)On Error GoTo uhohsQ = ""zz = Left(iString, 3)a = Left(zz, 1)b = Mid(zz, 2, 1)c = Mid(zz, 3, 1)d = Right(iString, 1)a = Int(Asc(a)) 'key 1b = Int(Asc(b)) 'key 2c = Int(Asc(c)) 'key 3d = Int(Asc(d)) 'key 4txt = Left(iString, Len(iString) - 1)txt2 = Mid(txt, 4, Len(txt)) 'encrypted texte = 1For x = 1 To Len(txt2)f = Mid(txt2, x, 1)    If e = 1 Then Q = Q & Chr(Asc(f) - a)  If e = 2 Then Q = Q & Chr(Asc(f) - b)  If e = 3 Then Q = Q & Chr(Asc(f) - c)  If e = 4 Then Q = Q & Chr(Asc(f) - d)e = e + 1If e > 4 Then e = 1Next xTDecrypt = QExit Functionuhohs:TDecrypt = "Error: Invalid text to Decrypt"Exit FunctionEnd FunctionFunction randomnumber (finished)Randomizerandomnumber = Int((Val(finished) * Rnd) + 1)End Function`

Posted: 2002-06-01
By: ArchiveBot
Viewed: 111 times

Categories

Visual Basic 6

Attachments

No attachments for this post