|
-
Nov 27th, 2003, 02:54 AM
#1
Thread Starter
Addicted Member
Encryption? How?
Hi i have made a simple IM client server app and was wondering
how i could encrypt the data the encryption doesn't need to be very strong
Code would be nice but just the theroy explination is what im looking for since im confused
Sam Lad
-
Nov 27th, 2003, 02:58 AM
#2
Addicted Member
well, how simple is simple? your could just replace a with z, b with y, c with x, etc.. that's extremely simple. or you could use whatever letters you wanted. there's way better than that, but that's pretty simple.
too simple?
C++/VB6&.NET/QBasic/HTML/PHP/MySQL/SQLServer2k
I'm the guy your little brother looks a lot alike. Tell your mom i said thanks.
naked in vegas
-
Nov 27th, 2003, 03:02 AM
#3
Fanatic Member
Hehe my old "simple" encryption method was take the asc value of the character and add 20 to it 
It was good enough for what it was doing.. on a small business app that no one there knew how to use a computer to even look at non encrypted files anyway. They just knew how to enter the data haha.
-
Nov 27th, 2003, 03:13 AM
#4
Thread Starter
Addicted Member
thanks all
thank you people
but how do i get the key ascii values for a string varible?
for example
VB Code:
dim msg as string
dim username as string
username = "bob"
msg = username & " says... " & txtmsg.txt
msg 'encrypt here????
Winsockout.sendData msg
-
Nov 27th, 2003, 03:22 AM
#5
Fanatic Member
VB Code:
dim msg as string
dim username as string
dim i as long
dim nmsg as string
username = "bob"
msg = username & " says... " & txtmsg.txt
nmsg = ""
for i = 1 to len(msg)
nmsg = nmsg & (asc(mid(msg,i,1)) + 20)
next
msg = nmsg
Winsockout.sendData msg
That would perform the encryption method I spoke of.
-
Nov 27th, 2003, 03:36 AM
#6
Thread Starter
Addicted Member
would this work for the decrpyting?
VB Code:
Dim strData As String
' get the data and add it to the listbox
Winsock1.GetData strData
for i = 1 to len(strData)
nmsg = nmsg & (asc(mid(strData,i,1)) - 20)
next
msg = nmsg
lstconvo.add item msg
would that work???
thanks for the code i greatly appricate it thanks mate
thanks all
-
Nov 27th, 2003, 03:39 AM
#7
Hyperactive Member
I have a litte function to do this
VB Code:
Public Function EncryptText(ByVal sMessage As String, Optional ByVal nCode As Long = -1) As String
Dim i As Long, sRet As String, nAscii As Long
If Len(sMessage) = 0 Then
EncryptText = ""
Exit Function
End If
If nCode < 0 Then
nCode = G_Shift_Char
End If
sRet = ""
For i = 1 To Len(sMessage)
nAscii = Asc(Mid$(sMessage, i, 1)) + nCode
If nAscii >= 255 Then nAscii = nAscii - 223
sRet = sRet & Chr(nAscii)
Next i
EncryptText = sRet
End Function
Public Function DecryptText(ByVal sCode As String, Optional ByVal nCode As Long = -1) As String
Dim i As Long, sRet As String, nAscii As Long
If Len(sCode) = 0 Then
DecryptText = ""
Exit Function
End If
If nCode < 0 Then
nCode = G_Shift_Char
End If
sRet = ""
For i = 1 To Len(sCode)
nAscii = Asc(Mid$(sCode, i, 1)) - nCode
If nAscii < 32 Then nAscii = nAscii + 223
sRet = sRet & Chr(nAscii)
Next i
DecryptText = sRet
End Function
This will shift ASCII code by specific value
Don't leave it till tomorrow, Do It Now!
5361726176757468204368616E63686F747361746869656E

-
Nov 27th, 2003, 03:56 AM
#8
Thread Starter
Addicted Member
thanks csar but my code works ok
thanks for all ya help people
-
Nov 27th, 2003, 04:10 AM
#9
Thread Starter
Addicted Member
More than one client on server??
Hi my winsock set up will only allow one user at a time could someone explain to me how i could ammend this so that many users can use the server at once
code not nessacary just a explanation
thanks all
Sam Lad
-
Nov 27th, 2003, 04:46 AM
#10
Fanatic Member
I'm not an expert on winsock.. heck I probably just a beginner with it but to my understanding the easiest way to allow multiple users is to create the winsock as a control array.
Have one watching a port for connections then after that create a new array for each user that connects. Or have it setup so it tries connecting and the client changes ports until it finds an open port on the server and just stay there. Send input through the connection for what port the user is assigned to and change the winsock controls there to connect through that port. Keep up via a database or something what user is on what control array or port and then you can send messages between the ports server side to get the messages from user to another.
This would work for a simple program like your doing. Not sure if there is a more complex way of doing it or not.
-
Nov 27th, 2003, 05:51 AM
#11
Hyperactive Member
hey for encryption there are a lot of options :
1. simplest : make a mapping list like a= 2, b=c and change each character like this.this is easy to decrypt
2. find th acsii value and then add a number to it and store it.be careful when the value after adding becomes more than 255.
3. like 2 but donnt add a fixed number , rather generate a random number and store it in the file itself at some particular position.this is a bit diff. to hack
4. there are some standard encryption alogos available also.
best a luck
-
Nov 29th, 2003, 08:04 AM
#12
Frenzied Member
I use and stand by RC4 encryption, it is very secure.
-
Dec 9th, 2003, 11:49 AM
#13
Member
if you want to start from nil in encription techniques, try this:
instead of doing a=1, b=2 try:
convert each letter of your message to it's decimal number, and then convert the number to an binary number and then apply:
bynary number XOR key
key, is the password for encryption.
E.g.(with ficticious numbers):
Message => P
Password (in this case just one letter) = G
P -> 76 -> 01100010
Do: (01100010) XOR (bynary number of G)
and there you have an encription method for the message P.
Did you get it ?
-
Dec 9th, 2003, 06:33 PM
#14
Lively Member
For multipe winsock connections, I have the same thing that StevenHickerson refers to...
VB Code:
'1st WinSock control = tcpServer
'2nd WinSock control = Link() [a control array]
Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
Dim lIndex As Long
Dim lCount1 As Long
'Part 1 : Check for available links (not loaded/connected)
lIndex = -1
For lCount1 = 1 To MAX_LINKS
If Me.Link.UBound < lCount1 Then Load Me.Link(lCount1)
If Not LinkConnected(lCount1) Then
lIndex = lCount1
Exit For
End If
Next lCount1
'Part 2 : Connect the client to Link(lIndex) instead of the tcpServer that they originally contacted.
If lIndex = -1 Then
MsgBox("No more connections available")
Else
Me.Link(lIndex).Close
Me.Link(lIndex).Accept requestID
End If
End Sub
Private Sub link_DataArrival(iIndex As Integer, ByVal lTotalBytes As Long)
Dim sReceiveString As String
Me.Link(iIndex).GetData sReceiveString, vbString
'Process (iIndex indicates the client that connected)
End Sub
-
Feb 11th, 2004, 02:23 PM
#15
Fanatic Member
Spajeoly
Please tell me more about the RC 4 encrytion....
-
Feb 11th, 2004, 05:11 PM
#16
Fanatic Member
here is part of an encryption I devised that uses text hashing for any ascii values < 128
Any comments??
VB Code:
Private sData As String
Public Function Encrypt(Data As String, Key As String) As String
Dim byt() As Byte
Dim l As Long
Dim m As Long
Dim s As String
Dim s1 As String
'convert to byte array
For l = 0 To Len(Data) - 1
ReDim Preserve byt(l)
byt(l) = Asc(Mid(Data, l + 1, 1))
Next
'byt = Data
'hash the key with the data.
For l = 0 To UBound(byt)
m = m + 1
If m > Len(Key) Then m = 1
If byt(l) < 128 Then
byt(l) = byt(l) + Asc(Mid(Key, m, 1))
End If
'l = l + 1
Next
For l = 0 To UBound(byt)
s = s & Chr(byt(l))
Next
Encrypt = s
sData = s
Debug.Print s
End Function
Public Function Decrypt(ByVal Encrypted As String, Key As String) As String
Dim byt() As Byte
Dim l As Long
Dim m As Long
Dim s As String
Dim s1 As String
s = Encrypted
ReDim byt(Len(s) - 1)
m = 0
For l = 1 To Len(s)
m = m + 1
If m > Len(Key) Then m = 1
byt(l - 1) = Asc(Mid(s, l, 1))
byt(l - 1) = byt(l - 1) - Asc(Mid(Key, m, 1))
s1 = s1 & Chr(byt(l - 1))
Next
Debug.Print s1
Decrypt = s1
sData = s1
End Function
Public Sub SaveToFile(FileName As String)
Dim l As Long
l = FreeFile
Open FileName For Binary Access Write As #l
Put #l, 1, sData
Close #l
End Sub
-
Feb 11th, 2004, 08:35 PM
#17
Frenzied Member
for encryption, everyone seems to have done something similair to what I did:
http://acid.freewebpage.org/VB/0007.zip
What I want to know is, how do you encrypt a file? like for instance a .jpg file.
Have I helped you? Please Rate my posts. 
-
Feb 11th, 2004, 09:25 PM
#18
Originally posted by Spajeoly
I use and stand by RC4 encryption, it is very secure.
RC4 is a good algorithm, i personally prefer AES(Advanced Encription Standard), thought its a bit slow encrypting large volume of data.
I wrote a application which encrypts message using AES and sends throug MSN Messenger, works pretty well for me. You can use the Msn Messenger API to send and receive the messages. Just simply decrypt it before displaying and encrypt them before sending.
You could find vb implementation of AES on the Net, if you cant i have one in my libray if you interested i can dig it out.
Hope this helps.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
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
|