|
-
Nov 7th, 2002, 12:35 AM
#1
Thread Starter
Frenzied Member
Packet Compression
OK. I figured out how to compress strings! No one here knew howto, so I think it might be useful to look at this.
Heres an ip address...
127.234.111.133 (32 byte string)
êo… (8 bytes)
Both are the same IP address. Both are in string format.
the later is converted with this code, which can easily be converted back a minute later.
This isnt encryption by any means.
Its the exact way your computer stores information.
VB Code:
Public Function MakeDWORD(Data As Long) As String
Dim tmp As String, a As String, b As String, c As String, d As String
tmp = Right("00000000" & Hex(Data), 8)
a = Mid(tmp, 1, 2)
b = Mid(tmp, 3, 2)
c = Mid(tmp, 5, 2)
d = Mid(tmp, 7, 2)
MakeDWORD = Chr(Val("&H" & d))
MakeDWORD = MakeDWORD & Chr(Val("&H" & c))
MakeDWORD = MakeDWORD & Chr(Val("&H" & b))
MakeDWORD = MakeDWORD & Chr(Val("&H" & a))
End Function
Public Function MakeWORD(Data As Integer) As String
Dim tmp As String, a As String, b As String
tmp = Right("0000" & Hex(Data), 4)
a = Mid(tmp, 1, 2)
b = Mid(tmp, 3, 2)
MakeWORD = Chr(Val("&H" & b))
MakeWORD = MakeWORD & Chr(Val("&H" & a))
End Function
Public Function MakeBYTE(Data As Byte) As String
Dim tmp As String
MakeBYTE = Chr(Val("&H" & Right("00" & Hex(Data), 2)))
End Function
Public Function ToNumeric(ByVal hSource As Variant) As String
Select Case Len(hSource)
Case 1
ToNumeric = Right("00" & Hex(Asc(hSource)), 2)
Case 2
one = Mid(hSource, 1, 1)
two = Mid(hSource, 2, 1)
ToNumeric = Right("00" & Hex(Asc(two)), 2)
ToNumeric = ToNumeric & Right("00" & Hex(Asc(one)), 2)
Case 4
one = Mid(hSource, 1, 1)
two = Mid(hSource, 2, 1)
three = Mid(hSource, 3, 1)
four = Mid(hSource, 4, 1)
ToNumeric = Right("00" & Hex(Asc(four)), 2)
ToNumeric = ToNumeric & Right("00" & Hex(Asc(three)), 2)
ToNumeric = ToNumeric & Right("00" & Hex(Asc(two)), 2)
ToNumeric = ToNumeric & Right("00" & Hex(Asc(one)), 2)
End Select
ToNumeric = Val("&H" & ToNumeric)
End Function
-
Nov 7th, 2002, 12:40 AM
#2
Frenzied Member
You make it too hard...
Code:
Dim Octets
Octets = Split(IP, ".")
Dim ret As String
ret = ret & chr(cint(octets(0)))
ret = ret & chr(cint(octets(1)))
ret = ret & chr(cint(octets(2)))
ret = ret & chr(cint(octets(3)))
Code:
Dim ret as String
ret = cstr(asc(mid(cmpd_ip, 1, 1)))
ret = ret & "."
ret = ret & cstr(asc(mid(cmpd_ip, 2, 1)))
ret = ret & "."
ret = ret & cstr(asc(mid(cmpd_ip, 3, 1)))
ret = ret & "."
ret = ret & cstr(asc(mid(cmpd_ip, 4, 1)))
Should work...
Z.
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
|