stack.cpp

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

CPP
64
字号
/*An Botan example application showing how to use the pop and prepend functionsof Pipe. Based on the md5 example. It's output should always be identical tosuch.Written by Jack Lloyd (lloyd@randombit.net), Feb 3, 2002This file is in the public domain*/#include <iostream>#include <fstream>#include <botan/filters.h>int main(int argc, char* argv[])   {   if(argc < 2)      {      std::cout << "Usage: stack <filenames>" << std::endl;      return 1;      }   Botan::LibraryInitializer init;   Botan::Pipe pipe;   // this is a pretty vacuous example, but it's useful as a test   pipe.prepend(new Botan::Hash_Filter("MD5"));   pipe.prepend(new Botan::Hash_Filter("RIPEMD-160"));   pipe.prepend(new Botan::Chain(                   new Botan::Hash_Filter("RIPEMD-160"),                   new Botan::Hash_Filter("RIPEMD-160")));   pipe.pop(); // will pop everything inside the Chain as well as Chain itself   pipe.pop(); // will get rid of the RIPEMD-160 Hash_Filter   pipe.prepend(new Botan::Hash_Filter("SHA-1"));   pipe.append(new Botan::Hex_Encoder);   pipe.prepend(new Botan::Hash_Filter("SHA-1"));   pipe.pop(); // Get rid of the Hash_Filter(SHA-1)   pipe.pop(); // Get rid of the other Hash_Filter(SHA-1)       // The Hex_Encoder is safe because it is at the end of the Pipe,       // and pop() pulls off the Filter that is at the start.   pipe.prepend(new Botan::Hash_Filter("RIPEMD-160"));   pipe.pop(); // Get rid of that last prepended Hash_Filter(RIPEMD-160)   int skipped = 0;   for(int j = 1; argv[j] != 0; j++)      {      std::ifstream file(argv[j]);      if(!file)         {         std::cout << "ERROR: could not open " << argv[j] << std::endl;         skipped++;         continue;         }      pipe.start_msg();      file >> pipe;      pipe.end_msg();      file.close();      pipe.set_default_msg(j-1-skipped);      std::cout << pipe << "  " << argv[j] << std::endl;      }   return 0;   }

⌨️ 快捷键说明

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