VB icon

A simple encryption module

Email
Submitted on: 1/23/2015 1:15:00 PM
By: NL_Programmer (from psc cd)  
Level: Beginner
User Rating: By 7 Users
Compatibility: VB 6.0
Views: 1308
 
     This is a quick little encryption file I put togeather in about half an hour. It's reasonably secure for whatever you want to use it for Feel free to add this to whatever program you want to.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: A simple encryption module
' Description:This is a quick little encryption file I put togeather in about half an hour. It's reasonably secure for whatever you want to use it for
Feel free to add this to whatever program you want
to.
' By: NL_Programmer (from psc cd)
'
' Returns:The "Encrypt" call turns the message you call it with into a set of numbers and the "Decrypt" call takes those numbers and turns them back into a string.
'**************************************

' Both of these functions return a string value
' just call the encrypt and it returns a set of numbers
'
' decrypt takes the set of numbers and decrypts it
' sweet and simple but it works well to make save files (At least thats what I use it for)
'
' P.S. Don't mess with anything. It works as it does and I
' Don't feel like comenting every line
Public Function encrypt(Message As String) As String
Randomize
On Error GoTo errorcheck
Dim tempmessage As String
Dim basea As Integer
Dim tempbasea As String
Message = Reverse_String(Message)
tempmessage = CStr(Message)
basea = Int(Rnd * 75) + 25
If basea < 0 Then
tempbasea = CStr(basea)
tempbasea = Right(tempbasea, Len(tempbasea) - 1)
basea = CInt(tempbasea)
End If
basea = basea / 2
encrypt = CStr(basea) + ";"
For x = 1 To Len(tempmessage)
encrypt = encrypt + CStr(Asc(Left(tempmessage, x)) - basea) + ";"
basea = basea + 1
tempmessage = Right(tempmessage, Len(tempmessage) - 1)
Next x
errorcheck:
End Function
Public Function decrypt(code As String) As String
On Error GoTo errorcheck
Dim basea As Integer
Dim tempcode As String
Do Until Left(code, 1) = ";"
tempcode = tempcode + Left(code, 1)
code = Right(code, Len(code) - 1)
Loop
basea = CInt(tempcode)
tempcode = ""
code = Right(code, Len(code) - 1)
Do Until code = ""
Do Until Left(code, 1) = ";"
tempcode = tempcode + Left(code, 1)
code = Right(code, Len(code) - 1)
Loop
decrypt = decrypt + Chr(CLng(tempcode) + basea)
code = Right(code, Len(code) - 1)
tempcode = ""
basea = basea + 1
Loop
decrypt = Reverse_String(decrypt)
errorcheck:
End Function
Public Function Reverse_String(Message As String) As String
For x = 1 To Len(Message)
Reverse_String = Reverse_String + Left(Right(Message, x), 1)
Next x
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 Beginner 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.