当使用块加密算法时, Cipher类会自动添加padding到输入数据中,来适配相应块大小。可调用cipher.setAutoPadding(false)禁用默认padding。

autoPaddingfalse时,整个输入数据的长度必须是cipher块大小的倍数,否则将抛出一个错误。 禁用自动填充对于非标准填充是有用的,例如使用0x0代替PKCS填充。


When using block encryption algorithms, the Cipher class will automatically add padding to the input data to the appropriate block size. To disable the default padding call cipher.setAutoPadding(false).

When autoPadding is false, the length of the entire input data must be a multiple of the cipher's block size or will throw an error. Disabling automatic padding is useful for non-standard padding, for instance using 0x0 instead of PKCS padding.

The cipher.setAutoPadding() method must be called before