• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Blowfish encryption algorithm

BigJohnKC

Platinum Member
I have to use this encryption algorithm for the application that I am working on, and I was wondering if any of you could help me. I don't know a whole lot about encryption, and every resource that I've found about blowfish is talking in highly technical language, assuming you are well-versed in the encryption vernacular. What I need to know is this: sometimes when I encrypt using blowfish the resulting encrypted string is not able to be decrypted by the same cipher key. I read something about length in bytes of the key, or length of the string to encode or something, but I am confused as to what I need to change to make it work. I was just wondering if any of you all have had experience with blowfish, and maybe you could help me. Thanks in advance.
 
Assuming you're working with a correct implementation of Blowfish, only tricky part is that there are up to 3 or 7 (I forget) extra bytes in the encoded string since it works in 4- or 8-byte chunks. So you may need to store the real length and chop the extras off once you decode, e.g. 13 bytes encodes as 16, decodes as 16, must ignore last 3.
 
I've been taking care of this length problem by padding the end of the string I'm encoding to ensure the size in bytes is a multiple of 8, as it seems that is the magic number. I think I may have a broken implementation of blowfish (BTW, I'm doing this in java), as a plaintext that is 16 bytes long with an 8 byte key produces what looks like a valid ciphertext, but the decode algorith cannot decode it properly back to its original form. Can you suggest a good java implementation of blowfish?
 
Back
Top