加密里面的padding

在使用加密模块的时候,比如javax.crypto.Cipher,会碰到padding不同的形式。在java里面规定了如下几种padding:

NoPadding: No padding.

 

OAEPWith<digest></digest>And<mgf></mgf>Padding: Optimal Asymmetric Encryption Padding scheme defined in PKCS #1, where <digest></digest>should be replaced by the message digest and <mgf></mgf>by the mask generation function. Example: OAEPWithMD5AndMGF1Padding.

 

PKCS5Padding: The padding scheme described in: RSA Laboratories, "PKCS #5: Password-Based Encryption Standard," version 1.5, November 1993.

 

SSL3Padding: The padding scheme defined in the SSL Protocol Version 3.0, November 18, 1996, section 5.2.3.2 (CBC block cipher)

通过google查到这篇描述padding的文章讲的比较清楚:

http://www.di-mgt.com.au/cryptopad.html

不同的padding方式如下:

  1. Pad with bytes all of the same value as the number of padding bytes (pkcs#5)
  2. Pad with 0x80 followed by zero bytes
  3. Pad with zeroes except make the last byte equal to the number of padding bytes
  4. Pad with zero (null) characters
  5. Pad with space characters
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值