Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1245332
  • 博文数量: 76
  • 博客积分: 1959
  • 博客等级: 上尉
  • 技术积分: 2689
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-19 12:07
个人简介

樽中酒不空

文章分类

全部博文(76)

文章存档

2020年(4)

2019年(1)

2017年(2)

2016年(2)

2015年(7)

2014年(11)

2013年(13)

2012年(18)

2011年(2)

2010年(16)

分类: C/C++

2016-11-03 17:39:47

(cryptography)



1 Padding :

string text;
int len = text.size();
char chT = (AES_BLOCK_SIZE - len%AES_BLOCK_SIZE); 
for (int i = 0; i< (AES_BLOCK_SIZE - len%AES_BLOCK_SIZE); i++) 

text.push_back(chT); 

2 UnPadding:
char chT = out[len-1]; 
for (int i = 0; i < chT; i++)
{
if (out[len - i -1] != chT)
{
return len;
}
}


The padding will be one of:

01
02 02
03 03 03
04 04 04 04
05 05 05 05 05
etc.

This padding method (as well as the previous two) is well-defined if and only if N is less than 256.

Example: In the following example the block size is 8 bytes and padding is required for 4 bytes

... | DD DD DD DD DD DD DD DD | DD DD DD DD 04 04 04 04 |


阅读(4619) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~