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

前端 未结 2 909
一个人的身影
一个人的身影 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_*.

    0 讨论(0)
  • 2021-01-26 08:07

    From BF_ecb_encrypt man page:

    It encrypts or decrypts the first 64 bits of in using the key key, putting the result in out.

    Read the docs.

    0 讨论(0)
提交回复
热议问题