Results 1 to 7 of 7

Thread: [RESOLVED] Searching an encryption small which compress a string

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Resolved [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

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: Searching an encryption small which compress a string

    Quote Originally Posted by LaVolpe View Post
    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

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    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

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    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
  •  



Click Here to Expand Forum to Full Width