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

📄 mode_pad.cpp

📁 含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种CheckSum校验、多种MAC校验等几十种加密算法的程序
💻 CPP
字号:
/************************************************** CBC Padding Methods Source File                ** (C) 1999-2002 The Botan Project                **************************************************/#include <botan/mode_pad.h>#include <botan/util.h>namespace Botan {/************************************************** Pad with PKCS #7 Method                        **************************************************/void PKCS7_Padding::pad(byte block[], u32bit size, u32bit position) const   {   for(u32bit j = 0; j != size; j++)      block[j] = (size - position);   }/************************************************** Unpad with PKCS #7 Method                      **************************************************/u32bit PKCS7_Padding::unpad(const byte block[], u32bit size) const   {   u32bit position = block[size-1];   if(position > size)      throw Decoding_Error(name());   for(u32bit j = size - position; j != size; j++)      if(block[j] != position)         throw Decoding_Error(name());   return (size - position);   }/************************************************** Query if the size is valid for this method     **************************************************/bool PKCS7_Padding::valid_blocksize(u32bit size) const   {   if(size > 0 && size < 256)      return true;   else      return false;   }/************************************************** Pad with One and Zeros Method                  **************************************************/void OneAndZeros_Padding::pad(byte block[], u32bit size, u32bit) const   {   block[0] = 0x80;   for(u32bit j = 1; j != size; j++)      block[j] = 0x00;   }/************************************************** Unpad with One and Zeros Method                **************************************************/u32bit OneAndZeros_Padding::unpad(const byte block[], u32bit size) const   {   while(size)      {      if(block[size - 1] == 0x80)         break;      if(block[size - 1] != 0x00)         throw Decoding_Error(name());      size--;      }   if(!size)      throw Decoding_Error(name());   return (size - 1);   }/************************************************** Query if the size is valid for this method     **************************************************/bool OneAndZeros_Padding::valid_blocksize(u32bit size) const   {   if(size)      return true;   else      return false;   }}

⌨️ 快捷键说明

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