Results 1 to 3 of 3

Thread: Waiting for the cracker!

Threaded View

  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  

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