VB icon

CipherII

Email
Submitted on: 1/1/2015 9:50:00 PM
By: John Cui (from psc cd)  
Level: Not Given
User Rating: By 5 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 1119
 
     A StreamCipher encryption similar to the first 'Cipher' but now it can encrypt any text or binary file.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: CipherII
' Description:A StreamCipher encryption similar to the first 'Cipher' but now it can encrypt any text or binary file.
' By: John Cui (from psc cd)
'
' Inputs:PlainText(the text to be encrypted/decrypted), Secret(the password)
'
' Returns:Encrypted/Decrypted string
'
' Assumes:There is only one function to Encrypt/Decrypt the strings. It is to this point stable that you can encrypt the same string multiple times using different passwords every time and then decrypt in the reverse order.
'
' Side Effects:I tested the code in VB6.0 but I mainly used code that's been part of VB for a while so it should work with ver. 3 and up. One side effect is the cipher speed. It's still a little slow but I'm working on an 8, 16, and 32 cipher code which would hopefully be fast. Warning!! Keep the strings your working with in memory rather than in an object such as a textbox because there would be loss of data when a string with ascii < 32 is used in a textbox.
'**************************************

Public Function Cipher(PlainText, Secret)
Dim a, b, c
Dim pTb, cTb, cT
For i = 1 To Len(PlainText)
pseudoi = i Mod Len(Secret)
If pseudoi = 0 Then pseudoi = 1
a = Mid(Secret, pseudoi, 1)
b = Mid(Secret, pseudoi + 1, 1)
c = Asc(a) Xor Asc(b)
pTb = Mid(PlainText, i, 1)
cTb = c Xor Asc(pTb)
cT = cT + Chr(cTb)
Form1.Label1.Caption = i
DoEvents
Next i
EnCipher = cT
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.