Blowfish C++ does not correctly encrypt/decrypt.. why..?

前端 未结 2 923
一个人的身影
一个人的身影 2021-01-26 07:19

I have this piece of test code that uses Blowfish (openssl/blowfish.h) to encrypt, then decrypt a string. But when it comes out again, it hasn\'t been decrypted properly. Can an

2条回答
  •  滥情空心
    2021-01-26 08:00

    Blowfish operates on 64-bit blocks: that is, multiples of 8 bytes. BF_ecb_* processes a single such block. That's the first 8 characters of your string. The rest is ignored by BF_ecb_*. If you want to encrypt something longer, apply BF_ecb_* to one block after another in a loop if you're really happy to use the ECB mode, or use something like BF_ofb_*.

提交回复
热议问题