Results 1 to 2 of 2

Thread: [VB6] Hide Your Secrets the Easy Way!

Hybrid View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    [VB6] Hide Your Secrets the Easy Way!

    The Problem

    One of the things we run into now and then is the need to bury passwords or other secrets within our programs. Quite often we'll do something like encrypt the "secret" data as strings and use decryption logic at runtime to extract those actual "secret" values.

    But where do you do the encryption in the first place? Use a separate program and then copy/paste in the encrypted text? And how about later when you need to change such values and recompile? I hope you kept your little encryption program handy too.


    A Solution

    Here I offer an idea that came to me today: why not make the VB6 IDE do the encryption for you at design time? Then you can enter your secrets in plaintext when working on the program. No need for that second encryption program!

    In this case I have a demo UserControl I call ScrambleProps. It's only purpose is to hold a series of properties in its PropertyBag in encrypted form and decrypt them when your instance gets loaded. Here I just put in three simple properties: URL, User, and PW.

    You can change these to whatever properties you want to store encrypted. I recommend you replace the simple Scramble() routine I have in there with something a little stronger too of course.


    Easy and Secret

    If you compile this demo and look at the EXE with a hex viewer you won't find the plaintext values in there anywhere. Actually even if you look at the text of the .FRM file of the Form hosting ScrambleProps you'll only see the encrypted data!

    But when you run the program it will extract the decrypted values and display them in the Form.

    You enter your plaintext values... in the IDE's properties window!

    See the attached screenshot.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by dilettante; Apr 23rd, 2010 at 08:40 PM. Reason: typos

  2. #2
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: [VB6] Hide Your Secrets the Easy Way!

    wow, sound promising.
    something i was needed for a longtime.
    thank you very much for that!

    btw: thanks also for the console, using it always.

Tags for this Thread

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