w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Prevent user from editing text file when the program is closed

I'm not sure if this is even possible, so my suggestion is encrypting the data you want to store in the .txt file.

The following is a simple XOR encryption algorithm, if you want to decrypt the data, just run the method again with the encrypted string.

std::string crypt(std::string str, char key) { // If you want
to, you can apply proper const-ness
    std::string result = str; // Create a result string
    for (int i = 0; i < result.size(); i++) result[i] = str[i] ^ key; //
For every character in the string XOR it with the key
    return result; // Return the result

i hope this helped you.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.