VB icon

_ Unique Encryption Method

Email
Submitted on: 2/4/2015 7:55:00 PM
By: KRYO_11 (from psc cd)  
Level: Intermediate
User Rating: By 14 Users
Compatibility: VB 5.0, VB 6.0
Views: 1750
 
     Unique way to encrypt a file. I have posted an example of this, put this here just in case people did not feel like downloading it. This is my first encryption method. Wanted to make one that no other method used. So I came up with this. Please leave comments to let me know what you think of this, like I said it is my first so I would really appreciate some feedback. Thanks.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: _ Unique Encryption Method
' Description:Unique way to encrypt a file. I have posted an example of this, put this here just in case people did not feel like downloading it. This is my first encryption method. Wanted to make one that no other method used. So I came up with this. Please leave comments to let me know what you think of this, like I said it is my first so I would really appreciate some feedback. Thanks.
' By: KRYO_11 (from psc cd)
'**************************************

Public Function Encrypt(StringToEncrypt As String, Optional AlphaEncoding As Boolean = False) As String
 On Error GoTo ErrorHandler
 Dim Char As String
 Encrypt = ""
 
 For i = 1 To Len(StringToEncrypt)
Char = Asc(Mid(StringToEncrypt, i, 1))
Encrypt = Encrypt & Len(Char) & Char
 Next i
 
 If AlphaEncoding Then
 
StringToEncrypt = Encrypt
Encrypt = ""
For i = 1 To Len(StringToEncrypt)
 Encrypt = Encrypt & Chr(Mid(StringToEncrypt, i, 1) + 147)
Next i
 End If
 Exit Function
ErrorHandler:
 Encrypt = "Error encrypting string"
End Function
Public Function Decrypt(StringToDecrypt As String, Optional AlphaDecoding As Boolean = False) As String
 On Error GoTo ErrorHandler
 Dim CharCode As String
 Dim CharPos As Integer
 Dim Char As String
 
 If AlphaDecoding Then
 
Decrypt = StringToDecrypt
StringToDecrypt = ""
For i = 1 To Len(Decrypt)
 StringToDecrypt = StringToDecrypt & (Asc(Mid(Decrypt, i, 1)) - 147)
Next i
 End If
 
 Decrypt = ""
 
 Do
 
CharPos = Left(StringToDecrypt, 1)
StringToDecrypt = Mid(StringToDecrypt, 2)
CharCode = Left(StringToDecrypt, CharPos)
StringToDecrypt = Mid(StringToDecrypt, Len(CharCode) + 1)
Decrypt = Decrypt & Chr(CharCode)
 Loop Until StringToDecrypt = ""
 Exit Function
ErrorHandler:
 Decrypt = "Error decrypting string"
End Function


Other 19 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.