|
-
Aug 10th, 2007, 08:23 PM
#1
Thread Starter
Lively Member
Crypted Connection , needed ?
my project is file transfer ,
what I need is a way to encrypt and decrypt the data with a key , i did try to use modRC4.bas but the the sent file is damaged !
can you help me please ?
-
Aug 11th, 2007, 04:37 PM
#2
Re: Crypted Connection , needed ?
Kinda hard to help you without seeing:
1. Your code
2. The encryption code
3. What parts of the file you are encrypting and if you're decrypting those same parts
4. How you're transferring your file
etc...
-
Aug 17th, 2007, 11:57 AM
#3
Member
Re: Crypted Connection , needed ?
Here is a basic encryption/decryption algorithm that i created that works with string variables.
Read a chunk of the file at a time and pass it through EncryptString before sending. Then on receiving end use DecryptString on received data before writing to file.
Code:
Option Explicit
Private Const EncKey As String = "GST5DKHGV7VH4RK&^kmG8&%87TYKhg"
Public Function EncryptString(sData As String) As String
'Encryption
Dim keypos As Integer, i As Integer, buf As Integer
keypos = 1
If Len(sData) > 0 Then
'loop for every character
For i = 1 To Len(sData)
'perform ascii addition
buf = Asc(Mid(sData, i, 1)) + Asc(Mid(EncKey, keypos, 1))
'correct buffer if it goes over ascii limit
If buf > 255 Then
buf = buf - 256
End If
'Add to return parameter
EncryptString = EncryptString & Chr$(buf)
'advance keypos
If keypos = Len(EncKey) Then
keypos = 1
Else
keypos = keypos + 1
End If
Next i
End If
End Function
Public Function DecryptString(sData As String) As String
'Decryption
Dim keypos As Integer, i As Integer, buf As Integer
keypos = 1
If Len(sData) > 0 Then
'loop for every character
For i = 1 To Len(sData)
'perform ascii subtraction
buf = Asc(Mid(sData, i, 1)) - Asc(Mid(EncKey, keypos, 1))
'correct buffer if it goes over ascii limit
If buf < 0 Then
buf = 256 - Abs(buf)
End If
'Add to return parameter
DecryptString = DecryptString & Chr$(buf)
'advance keypos
If keypos = Len(EncKey) Then
keypos = 1
Else
keypos = keypos + 1
End If
Next i
End If
End Function

My ActiveX Controls Site
-
Aug 17th, 2007, 02:57 PM
#4
Re: Crypted Connection , needed ?
One should keep in mind that VB String variables should not be used for binary data. There are many places where the text of a String is converted from internal Unicode to ANSI/ASCII and back. Not all of these conversions are symmetric for all possible character values, some of which binary data may tend to run into more often than plain text.
-
Aug 18th, 2007, 06:23 AM
#5
Member
Re: Crypted Connection , needed ?
It depends on what sort of file is being sent. If the file is plaintext without special characters then strings are ok, however if your sending files like videos or music then you'll need to use a byte array.
The algorithm can easily be altered to work with byte arrays instead of strings

My ActiveX Controls Site
-
Aug 19th, 2007, 03:30 PM
#6
Thread Starter
Lively Member
Re: Crypted Connection , needed ?
I will try yours Lozzenger ...
Last edited by dBlues; Aug 19th, 2007 at 03:38 PM.
-
Aug 19th, 2007, 03:37 PM
#7
Thread Starter
Lively Member
Re: Crypted Connection , needed ?
thanx Lozzenger alot , it's working very well with all types of files
-
Aug 19th, 2007, 04:08 PM
#8
Thread Starter
Lively Member
Re: Crypted Connection , needed ?
but it increases size of data alot
-
Aug 19th, 2007, 04:34 PM
#9
Member
Re: Crypted Connection , needed ?
I don't see why it would increase the data size when it returns a string that's the same length as the one you passed in the function

My ActiveX Controls Site
-
Aug 21st, 2007, 11:15 AM
#10
Re: Crypted Connection , needed ?
Also be aware that if you're transferring the files by FTP, you have to specify binary transfer. ASCII transfer can modify a file.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Oct 29th, 2007, 06:54 PM
#11
Thread Starter
Lively Member
Re: Crypted Connection , needed ?
 Originally Posted by Lozzenger
It depends on what sort of file is being sent. If the file is plaintext without special characters then strings are ok, however if your sending files like videos or music then you'll need to use a byte array.
The algorithm can easily be altered to work with byte arrays instead of strings
how can I modify it to work with byte arrays instead of strings?
-
Nov 2nd, 2007, 05:19 AM
#12
Thread Starter
Lively Member
Re: Crypted Connection , needed ?
 Originally Posted by dBlues
how can I modify it to work with byte arrays instead of strings?
thnx
-
Nov 7th, 2007, 10:10 AM
#13
Re: Crypted Connection , needed ?
Is this still a question?
-
Nov 9th, 2007, 06:20 AM
#14
Thread Starter
Lively Member
Re: Crypted Connection , needed ?
 Originally Posted by Hack
Is this still a question?
yeah, I still can't modify it to work with byte arrays instead of strings
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
|