Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++/CLI
hi,
 
im trying to make a program that will only run for 50 times.
here's the sample of my code
 
config.ini
[Trial]
Value=1
main.cpp
string str = parse.get <std::string>("Trial.Value");
    int i;
    stringstream(str) >> i;
    
    if(i >= 51){
         exit(1);
         }else{
 
 
    int a = i + 1;    // problem here is it can only work once, after that it will                  
                      //stop adding. so im stuck with Value=2
    
    stringstream ss;
    ss << a;
    
    ofstream file("config.ini");
    file << "[Trial]";
    file << "\nValue=";
    file << (ss, ios::ate); //problem here (i think)..no matter what value i put
                            // in sample.ini for example Value=25 ...the output 
                            //will still be Value=2

    file.close();
 
what i want to do here is every time i will open this program it will add +1 in Value=1 until it reaches Value=50..please any way to do this?
 
thanks in advance
Posted 19-Aug-12 10:23am
Edited 19-Aug-12 10:33am
v5

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Clearly, this is not a hard scheme to crack. Given that you don't read it as an ini file, why not write a random stream of bytes, and come up with a way that the content all changes, so no-one can tell which byte is the one you're reading ( for example, use a hash and encode your sequence somehow so that it's not 1-50, for example if you create a random number generated with a hard coded seed, you can reproduce that sequence to count to what the 50th value is ).
 
I don't know off hand why this is not working, but if you change your code to something that might actually survive attempts to crack it, along the way you will probably find that you'll write something that works.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 19-Aug-12 23:00pm
   
Fair enough, my 5.
And I think the scheme devised by OP is just a pretty bad idea...
--SA
Juan _dela_cruz at 20-Aug-12 0:25am
   
thank you sir.. i just want to try to start from this(its just an example anyway)..yes i really plan to make it hard to crack..thanks again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CHill60 185
1 Sarvesh Kumar Gupta 185
2 OriginalGriff 179
3 George Jonsson 154
4 ArunRajendra 144


Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 19 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid