VB icon

A Simple encryption function with Password

Email
Submitted on: 1/8/2015 1:25:00 AM
By: Eskimoman (from psc cd)  
Level: Intermediate
User Rating: By 7 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 1290
 
     A simple encryption function with Password. The slightest change with the password will effect the text so that it is unreadable. This function also encrypts and decrypts depending on if you set EnDeCrypt Boolean to True or False. I am sure you could crack a message from this code after a while but i think it is stronger than other simple cryption codes you will find on planet source code. Sorry that I ain't REMed it but it is quite simple so you should understand it. I hope you like.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: A Simple encryption function with Password
' Description:A simple encryption function with Password. The slightest change with the password will effect the text so that it is unreadable. This function also encrypts and decrypts depending on if you set EnDeCrypt Boolean to True or False.
I am sure you could crack a message from this code after a while but i think it is stronger than other simple cryption codes you will find on planet source code.
Sorry that I ain't REMed it but it is quite simple so you should understand it. I hope you like.
' By: Eskimoman (from psc cd)
'
' Inputs:Text for encryption, Password and either true or false for encrypt or decrypt.
'
' Returns:The En/Decrypted text.
'
' Assumes:All you need to do is paste the code into a project and create a Command button. I useally put the function into a module.
'
' Side Effects:None I know off
'**************************************

Private Sub Command1_Click()
Dim Text As String, Password As String
Text = "Hello"
Password = "Pass"
Print Text
Text = Crypt(Text, Password, True)
Print Text
Text = Crypt(Text, Password, False)
Print Text
End Sub
Public Function Crypt(Source As String, strPassword As String, EnDeCrypt As Boolean) As String
'EnDeCrypt True = Encrypt
'EnDeCrypt False = Decrypt
Dim intPassword As Long
Dim intCrypt As Long
For x = 1 To Len(strPassword)
 intPassword = intPassword + Asc(Mid$(strPassword, x, 1))
Next x
For x = 1 To Len(Source)
If EnDeCrypt = True Then
 intCrypt = Asc(Mid$(Source, x, 1)) + intPassword + x
 
 Do Until intCrypt <= 255
 intCrypt = intCrypt - 255
 Loop
Else
 intCrypt = Asc(Mid$(Source, x, 1)) - intPassword - x
 
 Do Until intCrypt > 0
 intCrypt = intCrypt + 255
 Loop
End If
Crypt = Crypt & Chr(intCrypt)
Next x
End Function


Other 1 submission(s) by this author

 


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 Intermediate 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.