实施试验计划.[帮助] [英] Implementing Trial Scheme.[help]

查看:91
本文介绍了实施试验计划.[帮助]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图制作一个只能运行50次的程序.
这是我的代码示例

config.ini



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


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();



我要在这里做的是每次打开此程序时,它将在Value = 1中添加+1,直到达到Value = 50 ..请以任何方式执行此操作?

预先感谢



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

推荐答案

很显然,这不是一个很难破解的方案.鉴于您没有将其读取为ini文件,为什么不编写随机的字节流,并想出一种方法,使内容全部更改,所以没有人可以分辨出哪个字节是您要的那个字节.读取(例如,使用哈希值并以某种方式对序列进行编码,以使它不是1-50,例如,如果您创建一个由硬编码种子生成的随机数,则可以将该序列重现为第50个数字)值是).

我不知道为什么这是行不通的,但是如果您将代码更改为实际上可以幸免的某种东西,那么尝试破解它的过程中,您可能会发现自己会写出有效的东西.
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.


这篇关于实施试验计划.[帮助]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆