Results 1 to 9 of 9

Thread: [RESOLVED] Encryption

  1. #1

    Thread Starter
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Resolved [RESOLVED] Encryption

    Well I know there are millions of ways to encrypt text, but for some reason i like to complicate things and decided to attempt to create one. This is supposed to be encrypted one way only, so there is literally no way to decrypt it back. But I'm not sure if you can decrypt it back... so I'm wondering if i use something like this to encrypt data, would someone be able to convert it back?

    Also Randomize(Number) is used to Initializes the random-number generator, but what is the largest number that 'number' could be?

    VB Code:
    1. Function Encrypt(MyString As String)
    2.     Dim ValArray(255) As Long
    3.     Dim RetVal As String
    4.    
    5.     num = Len(MyString)
    6.    
    7.     Randomize (num)
    8.    
    9.     For x = 0 To 255
    10.         ValArray(x) = Int(Rnd * 255)
    11.     Next
    12.    
    13.     For y = 1 To Len(MyString)
    14.         RetVal = RetVal & Chr(ValArray(Asc(Mid(MyString, y, 1))))
    15.     Next
    16.    
    17.     Encrypt = RetVal
    18. End Function
    19.  
    20. Private Sub Command1_Click()
    21.     Label1.Caption = Encrypt(Text1.Text)
    22. End Sub

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Encryption

    If Rnd or Randomize is used then the string can be decrypted, thats what i heard from a microsoft evangelist at a seminar on encryption...

    the suggestion is crypto
    Last edited by ganeshmoorthy; Nov 23rd, 2006 at 07:04 AM.
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Encryption

    So this method would be unsafe to use? Or would it take a long while to crack?

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Encryption

    Quote Originally Posted by Andrew G
    So this method would be unsafe to use?
    Not really unsafe, I would say Yes. But it can be decrypted...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5
    Member
    Join Date
    Nov 2006
    Posts
    43

    Re: Encryption

    If the attacker knows the length of the string he can recreate the array of random numbers but he can't decrypt the text with any programs because it is possible that there are several elements in your array that has the same value. But by looking at the pattern an experienced person can decrypt it manually.

    When it comes to Randomize, it don't know the limit but i know it is high. Probably at least a double. It can take floating point seeds as well.

  6. #6

    Thread Starter
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Encryption

    mmm..... I suppose it back to the drawing board then... Thanks

  7. #7
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: [RESOLVED] Encryption

    Did you see this one by CVMichael?
    http://www.vbforums.com/showthread.php?t=231798

  8. #8

    Thread Starter
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: [RESOLVED] Encryption

    Ah i missed that. I've only seen his 128, 160 and 256 Bit File Encryption/Decryption with MD5, SHA1. Looks kinda similar to what I've tried but it works . Thanks, i'll come in handy later.

  9. #9
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: [RESOLVED] Encryption

    I just saw your thread...

    If you want to make a one way encryption, why not just use MD5 (or SHA1 or SHA256) Hash ? I have the classes in the High Encryption program you said you looked at it.

    Also, back to your algorithm, if you want it one way, you will make it much more difficult to break if you have the result constant, instead of preserving the original length.

    Also, it may or may not be decryptable because when you fill the array with random numbers, the random numbers could repeat. For example you could have "A" replaced with random number 10, and "B" with random number 10 again... therefore you won't be able to tell the original if it was replaced with the same number.
    But then again, if most replacements are with the same random number, then you could have 2 strings, having the same encryption result.

    That's exactly what hashing tries to accomplish (like MD5, SHA1, etc.), the chance that 2 strings have the same result is extremly minimal, in fact, that's where the hashing bits come into place.
    For example, for MD5 the chance that 2 strings have the same result is 2^128 = 3.4028236692093846346337460743177e+38 (since MD5 is 128 bit)

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