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

📄 s2k.cpp

📁 含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种CheckSum校验、多种MAC校验等几十种加密算法的程序
💻 CPP
字号:
/* This file is in the public domain */#include <vector>#include <string>#include <cstdlib>#include <botan/lookup.h>#include <botan/filters.h>#include <botan/pgp_s2k.h>using namespace Botan;/* A weird little hack to fit S2K algorithms into the validation suite   You probably wouldn't ever want to actually use the S2K algorithms like   this, the raw S2K interface is much more convenient for actually using them*/class S2K_Filter : public Filter   {   public:      void write(const byte in[], u32bit len)         { passphrase += std::string((const char*)in, len); }      void end_msg()         {         SymmetricKey x = s2k->derive_key(passphrase, outlen);         send(x, x.length());         }      S2K_Filter(S2K* algo, const SymmetricKey& s, u32bit o)         {         s2k = algo;         outlen = o;         s2k->change_salt(s, s.length());         }      ~S2K_Filter() { delete s2k; }   private:      std::string passphrase;      S2K* s2k;      u32bit outlen;   };Filter* lookup_s2k(const std::string& algname, const std::string& salt)   {   std::vector<std::string> name = parse_algorithm_name(algname);   if(name.size() == 0)      return 0;   const std::string s2k_name = deref_alias(name[0]);   if(s2k_name == "OpenPGP-S2K")      {      if(name.size() != 4)         throw Invalid_Algorithm_Name(algname);      return new S2K_Filter(new OpenPGP_S2K(name[1], to_u32bit(name[3])),                            salt, to_u32bit(name[2]));      }   return 0;   }

⌨️ 快捷键说明

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