1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Protect Buttons /Files with a Key

Discussion in 'Visual Basic 6' started by S0leil, Apr 23, 2013.

  1. S0leil

    S0leil Regular Member

    Joined:
    Feb 9, 2011
    Messages:
    463
    Likes Received:
    75
    Location:
    Germany
    Home Page:
    Hey guys,

    I just need some help. I want to make something like a "key protect" to my files. So the user needs to activate one button with entering a key into one textbox... Can you help me realising that? [​IMG]

    thanks!
     
  2. nocare

    nocare Junior Member

    Joined:
    Apr 29, 2013
    Messages:
    164
    Likes Received:
    81
    Location:
    Deep Code
    Well, in the simplest form.
    You generate a list of acceptable key's, or potentially manually create keys as needed. For example, a user buys the product and you ship a program set to work with only that key.

    Anyway, user enters key. Your program will then compare the input key to it's list of acceptable keys.
    Code:
    for (int = 0; i < acceptableKeys.length; i++)
    {
        if ( inputtedKey == acceptableKeys[i] )
        {
            doVerifiedProgram(inputtedKey);
        }
    }
    
    function doVerifiedProgram(String key)
    {
        saveFileToHardDriveOrRegistry(key);
    }
    
    function main(String[] args)
    {
         if (findKeyOnHardDriveOrRegistry() == true)
        {
           if (foundKeyIsValid() == true)
            {
               activated = true;
            }
        }
    }
    
    This is really pseudo-code, but the general and simple implementation is there. The save function will save the key in a file, registry or otherwise somewhat safe location, and the findKey function will look for the key at the designated save location. If it finds the key, it verifies that it is authentic when loading the program.

    Then your program set's a boolean that states the program is activated/verified, and any part of your program locked can be unlocked by checking against that boolean.

    Keep in mind, in terms of security, that boolean is the single point of failure for someone to crack. But there is really multiple ways this program could be attacked.

    BUT, its a good start for you.