当前位置: 首页>>代码示例>>C++>>正文


C++ DES::tripleEncrypt方法代码示例

本文整理汇总了C++中DES::tripleEncrypt方法的典型用法代码示例。如果您正苦于以下问题:C++ DES::tripleEncrypt方法的具体用法?C++ DES::tripleEncrypt怎么用?C++ DES::tripleEncrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DES的用法示例。


在下文中一共展示了DES::tripleEncrypt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

byte *encrypt( byte *dataIn , int len ) {

    unsigned int memsize = ((len/8)+1)*8; // round to the upper 8 byte size
    unsigned int nBlocks = ((len/8)+1);   // Number of blocks. There is at least one block
    unsigned int boffset = 0;             // Byte offset
    
    // WARNING WARNING WARNING WARNING
    byte *bout = (byte *)malloc(memsize); // THIS IS a very bad idea!!!! Just for testing. Allocation should be done OUTSIDE the function.
    
    while ( nBlocks > 0 ) {
        des.tripleEncrypt(&bout[boffset], &dataIn[boffset], key);
        boffset = boffset + 8;
        nBlocks = nBlocks - 1;
    };

    
    return bout;
}
开发者ID:fcgdam,项目名称:DES_Library,代码行数:18,代码来源:application.cpp

示例2: tdesTest

void tdesTest()
{
  byte out[8];
  byte in[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
  byte key[] = { 
                  0x3b, 0x38, 0x98, 0x37, 0x15, 0x20, 0xf7, 0x5e, // key A
                  0x92, 0x2f, 0xb5, 0x10, 0xc7, 0x1f, 0x43, 0x6e, // key B
                  0x3b, 0x38, 0x98, 0x37, 0x15, 0x20, 0xf7, 0x5e, // key C (in this case A)
                };
  
  Serial.println();
  Serial.println("====== Triple-DES test ======");
  
  //encrypt
  Serial.print("Encrypt...");
  unsigned long time = micros();
  des.tripleEncrypt(out, in, key);
  time = micros() - time;
  Serial.print("done. (");
  Serial.print(time);
  Serial.println(" micros)");
  printArray(out);
  
  //decrypt
  for (int i = 0; i < 8; i++)
  {
    in[i] = out[i];
  }
  Serial.print("Decrypt...");
  time = micros();
  des.tripleDecrypt(out, in, key);
  time = micros() - time;
  Serial.print("done. (");
  Serial.print(time);
  Serial.println(" micros)");
  printArray(out);
}
开发者ID:fcgdam,项目名称:DES_Library,代码行数:37,代码来源:application.cpp


注:本文中的DES::tripleEncrypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。