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

📄 ecb.cpp

📁 含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种CheckSum校验、多种MAC校验等几十种加密算法的程序
💻 CPP
字号:
/************************************************** ECB Mode Source File                           ** (C) 1999-2002 The Botan Project                **************************************************/#include <botan/ecb.h>namespace Botan {/************************************************** ECB Constructor                                **************************************************/ECB::ECB(const std::string& cipher_name, const SymmetricKey& key,         const std::string& n) :   BlockCipherMode(cipher_name, n, key, BlockCipherModeIV())   {   }/************************************************** Verify the IV is not set                       **************************************************/bool ECB::valid_iv_size(u32bit iv_size) const   {   if(iv_size == 0)      return true;   return false;   }/************************************************** Encrypt or Decrypt in ECB mode                 **************************************************/void ECB::write(const byte input[], u32bit length)   {   buffer.copy(position, input, length);   if(position + length >= BLOCK_SIZE)      {      process_block(buffer, buffer);      send(buffer, BLOCK_SIZE);      input += (BLOCK_SIZE - position);      length -= (BLOCK_SIZE - position);      while(length >= BLOCK_SIZE)         {         process_block(input, buffer);         send(buffer, BLOCK_SIZE);         input += BLOCK_SIZE;         length -= BLOCK_SIZE;         }      buffer.copy(input, length);      position = 0;      }   position += length;   }/************************************************** Finish encrypting or decrypting in ECB mode    **************************************************/void ECB::end_msg()   {   if(position)      throw Exception(name() + ": input was not in full blocks");   }/************************************************** ECB Encryption Constructor                     **************************************************/ECB_Encryption::ECB_Encryption(const std::string& cipher_name,                               const SymmetricKey& key) :   ECB(cipher_name, key, "ECB_Encryption")   {   }/************************************************** ECB Encryption Block Processing                **************************************************/void ECB_Encryption::process_block(const byte in[], byte out[])   {   cipher->encrypt(in, out);   }/************************************************** ECB Decryption Constructor                     **************************************************/ECB_Decryption::ECB_Decryption(const std::string& cipher_name,                               const SymmetricKey& key) :   ECB(cipher_name, key, "ECB_Decryption")   {   }/************************************************** ECB Decryption Block Processing                **************************************************/void ECB_Decryption::process_block(const byte in[], byte out[])   {   cipher->decrypt(in, out);   }}

⌨️ 快捷键说明

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