Click here to Skip to main content
Sign Up to vote bad
good
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:23
Edited 19 Aug '12 - 10:33


1 solution

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 - 19 Aug '12 - 23:00
Fair enough, my 5. And I think the scheme devised by OP is just a pretty bad idea... --SA
Juan _dela_cruz - 20 Aug '12 - 0:25
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 415
1 Arun Vasu 399
2 Sergey Alexandrovich Kryukov 368
3 Tadit Dash 198
4 Maciej Los 191
0 Sergey Alexandrovich Kryukov 9,955
1 OriginalGriff 7,589
2 CPallini 4,028
3 Rohan Leuva 3,422
4 Maciej Los 2,949


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