parse.cpp

来自「含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种Chec」· C++ 代码 · 共 69 行

CPP
69
字号
/************************************************** Parsing Functions Source File                  ** (C) 1999-2002 The Botan Project                **************************************************/#include <botan/util.h>#include <botan/exceptn.h>namespace Botan {/************************************************** Parse a SCAN-style algorithm name              **************************************************/std::vector<std::string> parse_algorithm_name(const std::string& namex)   {   if(namex.find('(') == std::string::npos &&      namex.find(')') == std::string::npos)      return std::vector<std::string>(1, namex);   std::string name = namex, substring;   std::vector<std::string> elems;   std::string::const_iterator i;   u32bit level = 0;   elems.push_back(name.substr(0, name.find('(')));   name = name.substr(name.find('('));   for(i = name.begin(); i != name.end(); i++)      {      char c = *i;      if(c == '(')         level++;      if(c == ')')         {         if(level == 1 && i == name.end() - 1)            {            if(elems.size() == 1)               elems.push_back(substring.substr(1));            else               elems.push_back(substring);            return elems;            }         if(level == 0 || (level == 1 && i != name.end() - 1))            throw Invalid_Algorithm_Name(namex);         level--;         }      if(c == ',' && level == 1)         {         if(elems.size() == 1)            elems.push_back(substring.substr(1));         else            elems.push_back(substring);         substring = "";         }      else         substring += c;      }   if(substring != "")      throw Invalid_Algorithm_Name(namex);   return elems;   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?