Results 1 to 2 of 2

Thread: What's wrong with this encryptor?

  1. #1

    Thread Starter
    Addicted Member kill_bill_gates's Avatar
    Join Date
    Oct 2004
    Posts
    222

    Exclamation What's wrong with this encryptor?

    hi,
    i've been making a simple string encryptor (in fact just imitating what i saw in a site but it was in php) and it seems to work quite good for some time. i don't know whether the problem is about the encryptor or decryptor so im sending both of the codes (it always has a problem with return but, when i dcrypt a long text, it just... starts making mistakes)
    And what it does is, it finds the sum of the ascii value of password, adds it to ascii value of each character of the message, and splits each character's ascii value into 3 random pieces and seperates each number with backslash
    frmEnc:
    VB Code:
    1. Option Explicit
    2. Dim PasswordSum As Integer, TextEncrypted As String
    3.  
    4. Private Sub Command1_Click()
    5. Dim E As String, i As Integer, ascE As Integer, Letter(1 To 3), E2 As String, ascE2 As Integer, EncLetter As Integer
    6. i = 0
    7. PasswordSum = 0
    8. TextEncrypted = ""
    9. Randomize Timer
    10. For i = 1 To Len(Text2.Text)
    11.   E = Mid(Text2.Text, i, 1)
    12.   ascE = Asc(E)
    13.   PasswordSum = PasswordSum + ascE
    14. Next
    15.  
    16. For i = 1 To Len(Text1.Text)
    17.     E2 = ""
    18.     Letter(1) = 0
    19.     Letter(2) = 0
    20.     Letter(3) = 0
    21.     EncLetter = 0
    22.     E2 = Mid(Text1.Text, i, 1)
    23.     ascE2 = Asc(E2)
    24.     EncLetter = ascE2 + PasswordSum
    25.     Letter(1) = Fix((Rnd * EncLetter) + 1)
    26.     Letter(2) = Fix((Rnd * EncLetter - Letter(1)) + 1)
    27.     Letter(3) = EncLetter - (Letter(1) + Letter(2))
    28.     TextEncrypted = TextEncrypted & "\" & Letter(1) & "\" & Letter(2) & "\" & Letter(3)
    29. Next
    30. Text3.Text = TextEncrypted
    31. End Sub
    32.  
    33. Private Sub Command2_Click()
    34. Load frmDec
    35. frmDec.Visible = True
    36. End Sub

    frmDec:
    VB Code:
    1. Dim Temp As String, LetterSum As Integer, PasswordSum As Integer, A(1 To 3) As Integer, TextDecrypted As String
    2. Private Sub Command1_Click()
    3. Temp = Text1.Text & "\"
    4. i = 0
    5. PasswordSum = 0
    6. Countsl = 0
    7. TextDecrypted = ""
    8. Text3.Text = ""
    9. For i = 1 To Len(Text2.Text)
    10.   E = Mid(Text2.Text, i, 1)
    11.   ascE = Asc(E)
    12.   PasswordSum = PasswordSum + ascE
    13. Next
    14. Tempa = Temp & "#"
    15. For q = 1 To Len(Tempa)
    16. For t = 1 To Len(Tempa)
    17. C = Mid(Tempa, q, t)
    18. If C = "\" Then Countsl = Countsl + 1
    19. Next
    20. Next
    21.  
    22. For j = 1 To (Countsl - 1) / 3
    23.  
    24. A(1) = 0
    25. A(2) = 0
    26. A(3) = 0
    27. LetterSum = 0
    28. A(1) = Val(Between("\", "\", Temp))
    29. Temp = Right(Temp, (Len(Temp) - Len(A(1)) - 1))
    30. A(2) = Val(Between("\", "\", Temp))
    31. Temp = Right(Temp, (Len(Temp) - Len(A(2)) - 1))
    32. A(3) = Val(Between("\", "\", Temp))
    33. Temp = Right(Temp, (Len(Temp) - Len(A(3)) - 1))
    34. LetterSum = (A(1) + A(2) + A(3)) - PasswordSum
    35. Text3.Text = Text3.Text + Chr(LetterSum)
    36. If Len(Temp) <= 1 Then MsgBox "Decryption Completed!"
    37. Next
    38. End Sub
    39. Private Function Between(Begining As String, Ending As String, TextToLookIn As String) As String
    40. Dim Be As String, En As String, TTLI As String
    41. Dim Length As Integer
    42. Be = Begining
    43. En = Ending
    44. TTLI = TextToLookIn
    45. TTLI = Right(TTLI, Len(TTLI) - (InStr(1, TTLI, Be) + Len(Be) - 1))
    46. If TTLI = "" Then Exit Function
    47. Between = Left(TTLI, InStr(1, TTLI, En) - 1)
    48. End Function
    any help will be appreciated
    "Quis custodiet ipsos custodes?"
    Juvenal
    Mete the Hun wanted to live in peace with the Chinese. So he gave the Chinese Emperor his favorite horse, best swords in his armory, and lots of other cool stuff. But then the Chinese Emperor asked for one thing. A useless land through the north. It was a small, useless, unproductive, uninhabited piece of land. But Mete the Hun's answer was certain:
    I gave you horses, weapons and much more which belonged to me. But the lands are not mine, it's my nation's and I'm ready to fight, kill and die for just an inch my country
    -=Joey Jordison R0CKS!! =-

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: What's wrong with this encryptor?

    You would be much bettr off using M$'s CAPICOM.dll to encrypt and decrypt data. You can google it. Good Luck.

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