当前位置: 首页>>代码示例>>C++>>正文


C++ Page::burn方法代码示例

本文整理汇总了C++中Page::burn方法的典型用法代码示例。如果您正苦于以下问题:C++ Page::burn方法的具体用法?C++ Page::burn怎么用?C++ Page::burn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page::burn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........

	if (enc) {
		cout << "[I] Encrypted msg:" << endl;

		Page   * page   = new Page;
		Crypto * crypto = new Crypto;

		// Get a usable page
		pnum = page->next(id);
		if (pnum == -1) {
			cout << "[E] Not found pages in book: " << id << endl;
			cout << "[I] You can generate them with: otpnitro -g -r " << id << endl << endl;
			exit(1);
		}

		// Read page X from Book (RECV ID)
		string out = page->read(pnum,id);

		if (msg.size() > out.size())
		{
			cout << "You need " << msg.size() - out.size() << " more bytes in the selected book page";
		        delete page;
		        delete crypto;
		        exit(1);
		}

		// Crypto
		string encrypted = crypto->encrypt(msg,out);

		// Print page
		Text * txt = new Text;
		txt->create(pnum,id,send,encrypted);
		cout << txt->print(1);

		delete txt;
		delete page;
		delete crypto;
		exit(0);
	}

	if (dec) {
		cout << "[I] Decrypted msg:" << endl;

		Page   * page   = new Page;
		Crypto * crypto = new Crypto;
		Text   * txt    = new Text;

		if (file.length() > 0)
			txt->parse(file);
		else
			txt->create(pnum,id,send,msg);

		// Read page X from Book (RECV ID)
		string out = page->read(txt->page,txt->book);

		if (out.length() == 0) {
			cout << "[E] The page " << pnum << " in the book " << id << " dont exist." << endl;
			cout << "[I] You can check if you recieved the " << id << " book, or if it was burned." << endl;
			cout << "[I] Check: otpnitro -l" << endl << endl;
			exit(1);
		}

		// Crypto
		txt->replaceAll(txt->msg," ","");
		txt->msg = crypto->decrypt(txt->msg,out);

		// Print MSG
		cout << txt->print(0);

		delete txt;
		delete page;
		delete crypto;
	   	exit(0);
	}

	if (brn) {
		cout << "[I] Burn page " << pnum;

		Page   * page   = new Page;
		if (page->burn(pnum,id))
		cout << ". OK"   << endl << endl;
		else
		cout << ". FAIL" << endl << endl;
		delete page;
		exit(0);
	}

	if (lst) {
		Page   * page   = new Page;

		cout << "[I] Available books:" << endl;
		cout << page->list();
		cout << endl;

		delete page;
		exit(0);
	}

	return(0);
}
开发者ID:capitanx,项目名称:otpnitro,代码行数:101,代码来源:otpnitro.cpp


注:本文中的Page::burn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。