How to solve javax.crypto.IllegalBlockSizeException: data not block size aligned

前端 未结 2 2237
滥情空心
滥情空心 2020-12-16 05:05

I am doing an assignment about use blowfish to do encryption & decryption in java.

I had added a provider, and get instance \"Blowfish/ECB/NoPadding\", but I sti

2条回答
  •  时光说笑
    2020-12-16 05:42

    You are using NoPadding and the size of your input data must not match the block size of the cipher, so an IllegalBlockSizeException is being thrown. If you use NoPadding you need to make sure that your input is a multiple of 8 bytes.

    Try specifying a padding scheme. Change to Blowfish/CBC/PKCS5Padding and it should work.

提交回复
热议问题