What are the cipher padding strings in java

后端 未结 2 1255
粉色の甜心
粉色の甜心 2020-12-08 19:39

Everyone talks about the padding schemes in ciphers but what are the actual strings one needs to pass in to the cipher? I don\'t care if they are symmetric or asymmetric, I

2条回答
  •  长情又很酷
    2020-12-08 20:11

    Block cyphers need padding, stream cyphers don't. Block cyphers need padding because they encrypt whole blocks, and your message may not exactly match a whole number of blocks. Padding is used to extend the message length to the next block boundary.

    See the Wikipedia article on Cryptographic padding for a lot of detail.

    For most purposes PKCS#7 (aka PKCS#5) padding is used: n bytes, all of value n:

    01
    02 02
    03 03 03
    ...
    10 10 10 10 ... 10 10
    

提交回复
热议问题