Results 1 to 2 of 2

Thread: Please Test This Encryption Scheme

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    8

    Lightbulb

    Here is a basic version of an encryption sscheme i devloped.
    If you have the time and the knowledge please test it.
    [list=A][*]Is it a strong encryption?[*]Did you brake it? How?[*]Any ideas for improvement?[/list=A]


    Code:
    Global dKey as Double,sKey as Double,D(255) As Byte
    Function Encrypt(OriginalFile)
            'Promt user to enter a Key: call Key(text1.text) 
            sfile=OriginalFile 
            Rnd (-dKey): Randomize dKey
            
            xfile = sfile & ".stdenc"
            Open sfile For Random As #1 Len = 1
            lenfile = LOF(1)
            Close
            
            ReDim C(lenfile) As Byte, x(lenfile) As Byte
            Open sfile For Binary As #1
            Get #1, 1, C()
            Close
            y = 0
            
            For i = 1 To lenfile
                y = y + 1
                y = y Mod 255 + 1
                x(i) = C(i) Xor D(y)
            Next i
            
            Open xfile For Binary As #1
            Put #1, 1, x()
            Close
    End Function
    
    Private Sub Key (x as String)
    
    For i = 1 To (Len(x) - 1)
        t = t + Asc(Mid(x, i, 1))
    Next i
    t = t - Asc(Mid(x, Len(x), 1))
    t = t ^ 2 - t
    Rnd (-t)
    Randomize t
    
    sKey = Int(Rnd * 2123234345) + 2000398
    dKey = Int(sKey / 1000 + 603)
    
    Rnd (-sKey)
    Randomize sKey
    
    For i = 1 To 255
        g = Int(Rnd * 255) + 1
        h = Int(Rnd * 255) + 1
        D(i) = g Xor h
    Next i
    
    End Sub
    Let me know what you think
    VB6

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    8

    Exclamation Explaination

    A breif explaination:
    First, the key is not stored in the encrypted file. A numder, i.e. TestNum, is created in the Key( ) sub, and stored in the encrypted file.
    The Key verification uses the User inputed key and the Key( ) sub to create a TestNum. If the TestNum created by Key( ) is the same as
    the TestNum in the encrypted file, then the encrypted file is decrypted.

    Second, the plainFile(unencrypted file) is loaded into an array.


    Code:
           Open sfile For Random As #1 Len = 1
            lenfile = LOF(1)
            Close
            
            ReDim C(lenfile) As Byte, x(lenfile) As Byte 'Create the array
            Open sfile For Binary As #1
            Get #1, 1, C() 'load whole file into array
            Close
    The array C( ) is then encrypted.

    Code:
           For i = 1 To lenfile
                y = y + 1
                y = y Mod 255 + 1
                x(i) = C(i) Xor D(y)
            Next i
    This method is faster than reading one byte, encrypting it, and then writing it.
    VB6

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