Results 1 to 3 of 3

Thread: Waiting for the cracker!

  1. #1

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Talking Waiting for the cracker!

    Hi guys,
    Since this forum is for all kinds of tasting I like to test this code before I post it in the code Bank. The code is in VB.Net and it has two functions Encrypt and Decrypt. I like to here your opinions about it and also if this code is good enough to encrypt a string expression that will be hard enough to crack down or not. In my opinion the encryption is pretty good. Basically, it xors the expression character with the key character at the time. Note it doesn’t xor the expression characters with the same key character but every time with deferent one. Since it does not have the same pattern with every char it makes encryption secure. For example: string “word” with the key “s2y” will be encrypted this way: letter ‘w’ will be xored with s,2,y, letter ‘o’ will be xored with s,2, letter ‘r’ will be xored with s, and letter ‘d’ will be xored with s,2,y. In addition it might have null characters as well so the text editors will not even show the text after the null char. And also to break the key is very difficult because the key can be any character including Unicode. Thus a key which has seven characters should be checked against 84,431,259,000 different combinations with only 126 ASCII characters. I can’t even imagine what would be the number with 254 or Unicode ASCII characters.
    VB Code:
    1. 'Author: Arman G.
    2. 'Created date: 10/04/2006
    3. Public Class ARGHendeCrypt
    4.     ''' <summary>
    5.     ''' Encrypts a string expression (Unicode also) and returns the encrypted string.
    6.     ''' </summary>
    7.     ''' <param name="_string">A string expression that will be encrypted.</param>
    8.     ''' <param name="key">A string key for encryption.</param>
    9.     Public Function Encrypt(ByVal _string As String, ByVal key As String) As String
    10.         Dim encryptString As String = ""
    11.         Dim i, i1, ascii As Integer
    12.  
    13.         If _string <> "" AndAlso key <> "" Then
    14.             i1 = key.Length - 1
    15.             For Each ch As Char In _string
    16.                 While i <= i1
    17.                     ascii = AscW(ch) Xor AscW(key.Substring(i))
    18.                     ch = ChrW(ascii)
    19.                     i += 1
    20.                 End While
    21.                 i = 0
    22.                 i1 -= 1
    23.                 If i1 < 0 Then
    24.                     i1 = key.Length - 1
    25.                 End If
    26.                 encryptString &= ChrW(ascii)
    27.             Next
    28.         End If
    29.         Return encryptString
    30.     End Function
    31.  
    32.     ''' <summary>
    33.     ''' Decrypts an encrypted string expression (Unicode also) and returns the decrypted string.
    34.     ''' </summary>
    35.     ''' <param name="_string">An encrypted string that will be decrypted.</param>
    36.     ''' <param name="key">A string key for decryption.</param>
    37.     Public Function Decrypt(ByVal _string As String, ByVal key As String) As String
    38.         Dim decryptString As String = ""
    39.         Dim i, i1, ascii As Integer
    40.  
    41.         If _string <> "" AndAlso key <> "" Then
    42.             For Each ch As Char In _string
    43.                 i = key.Length - 1
    44.                 While i - i1 >= 0
    45.                     ascii = AscW(ch) Xor AscW(key.Substring(i - i1))
    46.                     ch = ChrW(ascii)
    47.                     i -= 1
    48.                 End While
    49.                 i1 += 1
    50.                 If i1 > key.Length - 1 Then
    51.                     i1 = 0
    52.                 End If
    53.                 decryptString &= ChrW(ascii)
    54.             Next
    55.         End If
    56.         Return decryptString
    57.     End Function
    58. End Class
    Attached Images Attached Images  

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Waiting for the cracker!

    XOR encryption like this is not very secure.

    Think about it like this:

    You say that W is XoRed with S,2,y, which makes it more secure, but
    W XOR S XOR 2 XOR Y is no more secure than W XOR 8, because

    Code:
    W = 87 = 1010111
    S = 83 = 1010011
    2 = 50 = 0110010
    Y = 89 = 1011001
    ------------------
    If we XOR all of those together, we get 1101111

    Code:
    W = 87 = 1010111
    8 = 56 = 111000
    -----------------
    If we XOR these two together, we get 1101111

    W XOR S XOR 2 XOR Y = W XOR (S XOR 2 XOR Y), so to crack it instead of figuring out S,2, and Y, a cracker would have to only figure out the final value of S XOR 2 XOR Y which is 8 and XOR that with W.

    Building an application to hack this encryption would be pretty easy, especially if I know that the encrypted value was originally text. I could simply build an algorithm to XOR all values (1 to 256) with the first character. I could then narrow down which are likely choices (i.e. the XoR returns something in the clear text range). I then do that for each subsequent character. I will eventually have a small alphabet for each character to try, and that will result is much fewer permutations that I need to brute force.

    Also, since your input string and encrypted string are XORs they have the same number of characters. So I know the exact size of your input string, which can help me determine if I am on the right track.

    Finally, if I used this to encrypt text and I used the same key on two different text inputs and they started out the same (i.e. two sentences starting with the word "the"), the first four characters would be encrypted the exact same way.

    My suggestion to you, if you want something to go into the code bank would be to utilize some of the built in cryptography methods in the .net environment. They are located in the system.Security.Cryptography class.

  3. #3

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Waiting for the cracker!

    Thanks Negative0 you are absolutely right, it can be cracked very easily. Thanks for your input!

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