|
-
May 2nd, 2002, 04:08 PM
#1
Thread Starter
Fanatic Member
encryption
Hi, I,ve been wroking on an algorythm to encrypt data I save to
files... so far I,ve got it mixing and raising it.. I just wanted to
know how I could put... uh.. 'junk' characters in it. I,ve tried it but
nothing's worked so far. Here's what I've got so far...
---------------------------------------
Private Sub demix(code As Variant)
Dim code2 As String
code = CStr(code)
b = 1
Do Until a = Len(code) + 3
For a = 1 To Len(code) Step 2
If Asc(Mid(code, a, 1)) = b Then code2 = code2 + Mid(code, a + 1, 1): b = b + 1: c = True
If (b - 1) * 2 >= Len(code) Then GoTo 1
Next a
If c = False Then MsgBox "Decryption error", vbCritical, "Warning": Call raise(code): Exit Sub
c = False
Loop
1
code = code2
Text1.Text = code
End Sub
Private Sub mix(code As Variant)
Dim codeset() As Boolean
Dim code2 As String
Dim counter As Variant
code = CStr(code)
ReDim codeset(Len(code))
Do Until a = Len(code) + 1
a = Int(Rnd * Len(code)) + 1
If codeset(a) = False Then codeset(a) = True: code2 = code2 + Chr$(a): code2 = code2 + Mid(code, a, 1): counter = counter + 1
If counter = Len(code) Then a = Len(code) + 1
Loop
code = code2
Text1.Text = code
End Sub
Private Sub raise(code As Variant)
Dim code2 As String
code = CStr(code)
On Error GoTo 1
For a = 1 To Len(code)
code2 = code2 + Chr$(Asc(Mid(code, a, 1)) + 3)
Next a
code = code2
Text1.Text = code
Exit Sub
1
MsgBox "Encryption error", vbCritical, "Warning"
End Sub
Private Sub lower(code As Variant)
Dim code2 As String
code = CStr(code)
On Error GoTo 1
For a = 1 To Len(code)
code2 = code2 + Chr$(Asc(Mid(code, a, 1)) - 3)
Next a
code = code2
Text1.Text = code
Exit Sub
1
MsgBox "Decryption error", vbCritical, "Warning"
End Sub
Private Sub Command1_Click()
If Not Text1.Text = "" And Not Len(Text1.Text) > 255 Then
Call mix(Text1.Text)
Call raise(Text1.Text)
End If
End Sub
Private Sub Command2_Click()
If Not Text1.Text = "" And Not Len(Text1.Text) > 255 * 2 Then
Call lower(Text1.Text)
Call demix(Text1.Text)
End If
End Sub
-------------------------------------------
Here's "hello" after I've encrypted it 5 times:
&$ RD;~%> ,O
{7
P/+
Q
"#,+-0L8"' @<'&B*!9J CwGK!A4(H$2.NI%?)36#1.F
5{tS)E(-=:*M
any ideas?
Don't pay attention to this signature, it's contradictory.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|