Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Scrambling ((EXCEL 97/200))

    I need to scramble a sort of INI-(text) file to make it unreadable.

    My goal is that the scrambled file contains only 'printable' characters. I had thought to e.g. pad all lines to 80 chars; hide a key in each line and use that to encode (and decode) each line.
    Furthermore, I do not want external DLL's and/or OCX's required so all should be in VBA.

    I'm sure similar stuff has been done many times. Anyone who could share some code here?

    Thanks,

    Erik Jan

    PS. Coding has to prevent simple cracks only. The stuff I want to hide is not SUPER secret...

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scrambling ((EXCEL 97/200))

    VB Web has the code for <A target="_blank" HREF=http://www.vbweb.co.uk/show/1832>text string encryption</A>. Overkill, but the code is done and you can be really secure. For other options, search for VBA AND "encrypt text." HTH --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Reading/Swindon, Berkshire, United Kingdom
    Posts
    664
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scrambling ((EXCEL 97/200))

    As a complete aside, I just tried to follow that link - and here's what I found at <A target="_blank" HREF=http://www.vbweb.co.uk/show/1832>http://www.vbweb.co.uk/show/1832</A>


    Database Server Error

    DeveloperFusion.com would like to apologise for the current down-time. We have been unable (once again) to restart the MySQL database, and are (once again) waiting for Interland to do this for us.

    Once the database has been restarted, normal services will resume. You will also be glad to know that we will soon be transferring the entire website to MaximumASP.com; just as soon as we have re-written the whole site in ASP.NET and C#. If you would like to help us in this great feat, please contact us


    Now do they sound unhappy, or was it just the way I read it?

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scrambling ((EXCEL 97/200))

    <img src=/S/rofl.gif border=0 alt=rofl width=15 height=15> <img src=/S/rofl.gif border=0 alt=rofl width=15 height=15>
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  5. #5
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scrambling ((EXCEL 97/200))

    Here is a very simple Encryption/Decryption routine that uses XOR. In the Function pick a number that you want to use to scramble the text.

    The beauty of using XOR is that the same routine is used to Encrypt and Decrypt.

    Calling convention:

    Dim strEncryptedDecrypted as String
    Dim strStringToEncryptOrDecrypt

    strStringToEncryptOrDecrypt="Something to Encrypt"
    strEncryptedDecrypted=EncryptDecrypt(strStringToEn cryptOrDecrypt) ' Encrypt

    strStringToEncryptOrDecrypt=SomethingAlreadyEncryp ted
    strEncryptedDecrypted=EncryptDecrypt(strStringToEn cryptOrDecrypt) ' Decrypt



    Function EncryptDecrypt(strIn As String) As String

    Const XOR_VALUE As Byte = 123 ' Pick a value here between 1 and 255

    Dim i As Integer
    Dim strOut As String

    If Trim(strIn) = "" Then
    EncryptDecrypt = ""
    Exit Function
    End If

    For i = 1 To Len(strIn)
    strOut = strOut & Chr(Asc(Mid(strIn, i, 1)) Xor XOR_VALUE)
    Next i

    EncryptDecrypt = strOut

    End Function

    As I say, this is a very simple function and not particularly secure but I hope it helps.

    Regards,

    Kevin Bell

  6. #6
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scrambling ((EXCEL 97/200))

    Sam,

    Thanks for your suggestion. The code looks great and (very) secure. Problem is (as with the XOR suggested by Kevin) that the resulting code:
    1) is one big blob of characters
    2) contains non-printable characters

    I would so much like to see nice equal (because padded) length lines with all printable characters (I don't even care if these would al be numbers and realize there might be a trick here by replacing all chars by their ASCII codes).

    Erik Jan

  7. #7
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scrambling ((EXCEL 97/200))

    Erik,

    Here's a version of a simple Encryption and Decryption that is more akin to what you are looking for. I'm sorry the attachment is a Word document and not a spreadsheet. I realised that it was Excel you were talking about only after I had finished it. The code will work in Excel as there are no specific references to Word.

    Regards,

    Kevin Bell
    Attached Files Attached Files

  8. #8
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scrambling ((EXCEL 97/200))

    Great! Thanks Kevin... this helped me getting there 95%! I added an extra (simple) moving XOR (based on a random character I hide in the string). This allow equal length (padded) strings to be generated that do not have similar chars at the same locations...

    Erik Jan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •