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


C++ CommandLineOptions::getAlphabet方法代码示例

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


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

示例1:

//****************************************************************************
ErrorCode MD5UtilCore::processCollide (const CommandLineOptions& options, std::string& output) {

	static const std::string& NO_COLLISION_FOUND = "No collision found for current hash with given settings.";

	if (options.getHelpMode ()) {

		std::cout << MSG_COLLIDE_HELP << std::endl;
		return ErrorCode::NONE;

	}

	if (options.getInputText ().length () == 0 || options.getAlphabet ().length () == 0) {

		return ErrorCode::COLLIDE_USAGE_ERROR;

	}

	if (findCollision (options, output)) {

		if (options.getOutputFilename ().length () != 0) {

			if (!saveToFile (options.getOutputFilename (), output)) {

				return ErrorCode::FILE_WRITE_ERROR;

			}

		}

	} else {

		output = NO_COLLISION_FOUND;

	}

	return ErrorCode::NONE;

}
开发者ID:CharlesETD,项目名称:MD5Util,代码行数:39,代码来源:MD5UtilCore.cpp

示例2: plaintextGenerator

//****************************************************************************
void MD5UtilCore::checkCollisionRange (const CommandLineOptions& options, bool& solutionFound, std::string& output, const unsigned int threadIndex) {

	static const unsigned int MAX_DIGITS = 16;

	unsigned int threadCount = 1;
	unsigned int maxDigits = options.getMaxLength ();
	unsigned int minDigits = options.getMinLength ();
	uint_least64_t range = 0;
	uint_least64_t startIndex = 0;
	VBUInt plaintextGenerator (0, options.getAlphabet ().length ());
	std::string plaintextToTest;

	if (options.getThreadCount () > 1) {

		threadCount = options.getThreadCount ();

	}

	if (options.getMinLength () == 0 || options.getMinLength () > options.getMaxLength ()) {

		minDigits = 1;

	}

	if (options.getMaxLength () == 0 || options.getMaxLength () < options.getMinLength ()) {

		maxDigits = MAX_DIGITS;

	}

	range = plaintextGenerator.maxValue (maxDigits) / threadCount;
	startIndex = range * threadIndex;
	plaintextGenerator.setBaseTenValue (startIndex);

	for (; plaintextGenerator < VBUInt (startIndex + range); plaintextGenerator++) {

		for (unsigned int digits = minDigits; digits <= maxDigits; digits++) {

			if (solutionFound) {

				break;

			} else {

				plaintextToTest = plaintextGenerator.toString (options.getAlphabet ().getCharacters (), digits);

				if (hash (plaintextToTest) == options.getInputText ()) {

					solutionFound = true;
					output = plaintextToTest;
					break;

				}

			}

		}

	}

}
开发者ID:CharlesETD,项目名称:MD5Util,代码行数:62,代码来源:MD5UtilCore.cpp


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