|
-
Oct 5th, 2009, 06:48 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Searching an encryption small which compress a string
Hello ,
i'am sarching a string encryption cause i have a string which is like that
let's say :
Code:
EEbobzRwTeVzPFf01ERCjz6tnMnsYYAwMc9WJAs9LKV5aDN
i want to use an encryption which can let this string be smaller
thanks
-
Oct 5th, 2009, 07:03 PM
#2
Re: Searching an encryption small which compress a string
Off the top of my head, I can't think of any good encryption that actually reduces the size of the string by any significant amount. Most encryptions actually increase the size, unlike XOR encryption which maintains the same size.
You may want to consider using compression (i.e., Zip, ZLIB, Huffman, and other algorithms; search for "compression") to compress the string after it is encrypted. To decrypt, uncompress, then decrypt, in that order.
Edited: Compression alone can be considered encryption. However, two problems with using just compression: Some algorithms may not actually do any compression because doing so would make the string longer vs shorter and then your string ends up being open text. Another problem is that if you use common compression algorithms, anyone that recognizes it can decompress; thereby decrypt your strings.
-
Oct 5th, 2009, 07:09 PM
#3
Thread Starter
Fanatic Member
Re: Searching an encryption small which compress a string
 Originally Posted by LaVolpe
Off the top of my head, I can't think of any good encryption that actually reduces the size of the string by any significant amount. Most encryptions actually increase the size, unlike XOR encryption which maintains the same size.
You may want to consider using compression (i.e., Zip, ZLIB, Huffman, and other algorithms; search for "compression") to compress the string after it is encrypted. To decrypt, uncompress, then decrypt, in that order.
Edited: Compression alone can be considered encryption. However, two problems with using just compression: Some algorithms may not actually do any compression because doing so would make the string longer vs shorter and then your string ends up being open text. Another problem is that if you use common compression algorithms, anyone that recognizes it can decompress; thereby decrypt your strings.
the zip & ZLIB is to compress executable right ?
i'am just asking for vb6 string compress encryption
i will really appreciate some source or link from msdn cause i did search & only found CryptoAPI... not what i search
Thanks
-
Oct 5th, 2009, 07:13 PM
#4
Re: Searching an encryption small which compress a string
No, ZLIB can be used to compress anything. Strings are just a simple array of bytes. Many examples on this site for using ZLIB. But keep in mind what I said -- some compression routines will not compress if the result is actually larger than then source; this is one reason why compression should not be used as encryption.
If you have a planetsourcecode account, look at these for possibilities
P.S. A 47-character encrypted string is not very large at all. Can you describe exactly why something relatively small in size is considered large (everyone try to keep it clean )? Maybe there are other options/solutions.
Last edited by LaVolpe; Oct 5th, 2009 at 07:30 PM.
-
Oct 5th, 2009, 07:43 PM
#5
Thread Starter
Fanatic Member
Re: Searching an encryption small which compress a string
Thanks LaVolpe i really really appreciate your help
but i feel sorry to say that this not what i was waiting to get
i tought i will find some encryption function that can easy be done like rc4 or xor or others..
anyway Thanks i will try to think of something else until i find some good result
Thanks
-
Oct 5th, 2009, 07:51 PM
#6
Re: Searching an encryption small which compress a string
Xor is the easiest, but by far, a poor encryption. Simple example, not optimized.
Here is another PSC listing of possible projects to learn from, many types of encryption are presented.
Code:
Option Explicit
Private Sub Command1_Click()
Dim sEncrypted As String
sEncrypted = XORencrypt("EEbobzRwTeVzPFf01ERCjz6tnMnsYYAwMc9WJAs9LKV5aDN", 88)
MsgBox "Encrypted: " & sEncrypted
' to decrypt, pass encrypted string and same XOR value used to encrypt
MsgBox "Decrypted: " & XORencrypt(sEncrypted, 88)
End Sub
Private Function XORencrypt(sourceString As String, Optional ByVal XORvalue As Long = 127) As String
' pass XORvalue to any value btwn 1 and 255
Dim I As Integer
Dim newString As String
newString = sourceString
For I = 1 To Len(sourceString)
Mid$(newString, I, 1) = Chr$(Asc(Mid$(sourceString, I, 1)) Xor XORvalue)
Next
XORencrypt = newString
End Function
Edited: You can layer this type of encryption too to make it more secure. For example...
Code:
Private Sub Command1_Click()
Dim sEncrypted As String
sEncrypted = XORencrypt("EEbobzRwTeVzPFf01ERCjz6tnMnsYYAwMc9WJAs9LKV5aDN", 88)
sEncrypted = XORencrypt(sEncrypted, 122)
sEncrypted = XORencrypt(sEncrypted, 22)
sEncrypted = XORencrypt(sEncrypted, 199)
sEncrypted = XORencrypt(sEncrypted, 7)
Debug.Print sEncrypted
' to decrypt, pass encrypted string and same XOR value(s) used to encrypt, but in reverse order
sEncrypted = XORencrypt(sEncrypted, 7)
sEncrypted = XORencrypt(sEncrypted, 199)
sEncrypted = XORencrypt(sEncrypted, 22)
sEncrypted = XORencrypt(sEncrypted, 122)
Debug.Print XORencrypt(sEncrypted, 88)
Debug.Print "EEbobzRwTeVzPFf01ERCjz6tnMnsYYAwMc9WJAs9LKV5aDN"
End Sub
Last edited by LaVolpe; Oct 5th, 2009 at 08:01 PM.
-
Oct 6th, 2009, 11:21 AM
#7
Thread Starter
Fanatic Member
Re: Searching an encryption small which compress a string
Thanks dear LaVolpe Great help as always m8 
really appreciated
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
|