⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pipe_io.cpp

📁 含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种CheckSum校验、多种MAC校验等几十种加密算法的程序
💻 CPP
字号:
/************************************************** Pipe I/O Source File                           ** (C) 1999-2002 The Botan Project                **************************************************/#include <botan/pipe.h>#include <cstdio>#include <iostream>namespace Botan {/************************************************** Write data from a pipe into an ostream         **************************************************/std::ostream& operator<<(std::ostream& stream, Pipe& pipe)   {   static const u32bit BUFFERSIZE = DEFAULT_BUFFERSIZE;   SecureBuffer<byte, BUFFERSIZE> buffer;   while(stream.good() && pipe.remaining())      {      u32bit got = pipe.read(buffer, BUFFERSIZE);      stream.write((char*)buffer.ptr(), got);      }   if(!stream.good())      throw Stream_IO_Error("Pipe output operator (iostream) has failed");   return stream;   }/************************************************** Write data from a pipe into a stdio FILE       **************************************************/std::FILE* operator<<(std::FILE* stream, Pipe& pipe)   {   static const u32bit BUFFERSIZE = DEFAULT_BUFFERSIZE;   SecureBuffer<byte, BUFFERSIZE> buffer;   while(!std::ferror(stream) && pipe.remaining())      {      u32bit got = pipe.read(buffer, BUFFERSIZE);      std::fwrite(buffer, 1, got, stream);      }   if(std::ferror(stream))      throw Stream_IO_Error("Pipe output operator (stdio) has failed");   return stream;   }/************************************************** Read data from an istream into a pipe          **************************************************/std::istream& operator>>(std::istream& stream, Pipe& pipe)   {   static const u32bit BUFFERSIZE = DEFAULT_BUFFERSIZE;   SecureBuffer<byte, BUFFERSIZE> buffer;   while(stream.good())      {      stream.read((char*)buffer.ptr(), BUFFERSIZE);      pipe.write(buffer, stream.gcount());      }   if(stream.bad() || (stream.fail() && !stream.eof()))      throw Stream_IO_Error("Pipe input operator (iostream) has failed");   return stream;   }/************************************************** Read data from a stdio FILE into a pipe        **************************************************/std::FILE* operator>>(std::FILE* stream, Pipe& pipe)   {   static const u32bit BUFFERSIZE = DEFAULT_BUFFERSIZE;   SecureBuffer<byte, BUFFERSIZE> buffer;   while(!std::ferror(stream) && !std::feof(stream))      {      u32bit got = std::fread(buffer, 1, BUFFERSIZE, stream);      pipe.write(buffer, got);      }   if(std::ferror(stream))      throw Stream_IO_Error("Pipe input operator (stdio) has failed");   return stream;   }}

⌨️ 快捷键说明

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