VB icon

encryptAll

Email
Submitted on: 1/3/2015 1:37:00 AM
By: Bryan Hurley (from psc cd)  
Level: Not Given
User Rating: By 38 Users
Compatibility: VB 5.0, VB 6.0
Views: 568
 
     This simple encryption Function uses Xor encryption and itterative encoding to more securely encrypt a text string. Although the code is not unbreakable, it cannot be broken with a simple key. Itterative encoding ensures that code-cracking techniques, like character frequency study, will not work. It's as easy as could be. Function can be easily modified to encode more than strings.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: encryptAll
' Description:This simple encryption Function uses Xor encryption and itterative encoding to more securely encrypt a text string. Although the code is not unbreakable, it cannot be broken with a simple key. Itterative encoding ensures that code-cracking techniques, like character frequency study, will not work. It's as easy as could be. Function can be easily modified to encode more than strings.
' By: Bryan Hurley (from psc cd)
'
' Inputs:data As String, seed As Long Integer
'
' Returns:Function returns String of encoded/decoded text.
'
' Assumes:Module is set to Option Base 1. This is to simplify the code. If you are adding this to a pre-existing module, make sure that Base Option 1 will not adversely affect your other functions, or modify the code to work off of Base Option 0.
'**************************************

Public Function encryptAll(data As String, seed As Long) As String
Dim x As Integer, tmp As String, stepnum As Integer
Dim byteArray() As Byte, seedOffset As Integer, n As String
tmp = Trim$(Str(seed))
seed = 0
For x = 1 To Len(tmp)
n = Mid(tmp, x, 1)
 seed = seed + CLng(n)
Next x
 
reCheckSeed:
 If seed > 255 Then
seed = -1 + (seed - 255)
GoTo reCheckSeed
 End If
For x = 1 To Len(data)
 ReDim Preserve byteArray(x)
 n = Mid(data, x, 1)
 byteArray(x) = Asc(n)
 
 stepnum = seed + x
reCheckstepnum:
 If stepnum > 255 Then
stepnum = -1 + (stepnum - 255)
GoTo reCheckstepnum
 End If
 
 byteArray(x) = byteArray(x) Xor CByte(stepnum)
 
Next x
 tmp = ""
 For x = 1 To Len(data)
tmp = tmp & Chr(byteArray(x))
 Next x
encryptAll = tmp
End Function


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.