Folder Locker in C++ - Simple Hacks - Programming Concepts

Assalam-O-Alaikum! Welcome to Programming Concepts

    Today I'll share you a simple hack of locking folders in Windows. It's not much secure. But still it works.

Backbone

    The backbone of this Folder Locking technique is simple and easy. Windows recognizes files on the basis of their extensions. Like .mp4, .exe and .dll etc. If you change the extension Windows becomes unable to open the file in most cases. Usually Folders do not have any extension. But Zip Folder does. Because zip folders are files. If you change .zip to something like .ans. It won't be opened directly by double clicking. Rather Windows will ask you to choose a Program to open this file with.

    After changing the extension. We shall hide our folder so it becomes invisible. That's it.

    In C++ we shall do this using Command Prompt commands.

Let's Go

    Here's the video tutorial on Youtube:



    Open your IDE. Create a new project of C++ and insert following coding in it.
#include<stdlib.h> // To run DOS commands
#include<iostream>
#include<conio.h> // To use _getch command

using namespace std;

    Now we create our necessary functions (Lock(), Unlock() and getpass())
// Functions Declaration
int Lock(); // For Locking Folder
int Unlock(); // For Unlocking Folder
string getpass(); // For Getting Password from User

int Lock()
{
system("ren Folder.zip Keeper.ans"); // DOS command for renamming Folder.zip to Keeper.
system("attrib +h +s Keeper.ans"); // DOS command to assign hidden (+h) and system (+s) attributes to Keeper.ans
return 0;
}

int Unlock()
{
    system("attrib -s -h Keeper.ans"); // DOS command to remove system and hidden attributes
    system("ren Keeper.ans Folder.zip");
    return 0;
}

string getpass()
{
    string pass = "";
    char ch;
    ch = _getch();
    while (ch != 13) // 13 represents Enter key
    {
        if (ch != 8) // 8 represents Backspace key
        {
            pass.push_back(ch); // Put ch at the end of pass
            cout << "*";
        }
        else if (pass.length() > 0)
        {
            pass.pop_back(); // Pop out the last character from pass
            cout << "\b \b";
        }
        ch = _getch();
    }
    return pass;
}


    Now we shall create the main function as following.
int main()
{
    char choice;
    cout << "Welcome to Folder Locker:....." << endl << "What do you want to do?" << endl << "1: Lock" << endl << "2: Unlock" << endl << "> ";
    choice = _getch();
    if (choice == '1')
    {
        Lock(); // Calling our Lock() function
    }
    else if (choice == '2')
    {
        string pass = "";
        cout << endl << "Enter your Password: ";
        pass = getpass();
        if (pass == "1234") // Replace "1234" with your own password string
        {
            Unlock(); // Calling our Unlock() function
        }
        else
        {
            cout << "Password is incorrect";
        }
    }
    else
    {
        cout << endl << "Invalid Choice";
    }
    return 0;
}


    That's it. Now Compile and Run this code.
    Note: Make sure you create a zip folder with the name Keeper.zip in the same folder where your .exe file resides.

Comments

Popular Posts