in reply to Re^5: Decrypting BlowfishNET (try2)
in thread line by line Encryption fun with Crypt::CBC and Rijndael? File Ownership issues?

You are right about the padding, I am unsure as to how BlowfishSimple does it.

It doesn't you do it in the Encrypt function you presented.

The encrypt subroutine I pasted above was from from the BlowfishSimple class. It comes as part of the BlowfishNET download. I was comparing the libraries to see how the two encrypt and decrypt and I believe they pad differently. That is the reason I pasted the subroutine here. I thought I had mentioned it.

As far using the BlowfishSimple library/class, it pretty much boils down to making the following calls:

bfs = new BlowfishSimple(key); enc = bfs.Encrypt(plaintext);

So, as you can see that is why I keep querying about how the padding is done in BlowfishSimple, because that is what I thought is different, but then, I am not sure.

Thank you for your help.

Replies are listed 'Best First'.
Re^7: Decrypting BlowfishNET (try2)
by ikegami (Patriarch) on Aug 12, 2008 at 13:33 UTC

    BlowfishSimple:
    $fill = $unpadded_len % $block_size;

    Crypt::CBC (by default):
    $fill = $pad_size;

    size of padding
    01234567
    padded withBlowfishSimple76543210(For cyphers with a blocksize of 8)
    Crypt::CBC01234567

    Update: I accidentally had the note about blocksize dependence attached to Crypt::CBC. Fixed.

      One problem that you may have is that the NET function ConvertFromBase64 does not give the same result as perl MIME::Base64. The results look very similar but doing a hex dump of the perl and the NET versions shows that they are different. My ramblings on this subject are below. Don't treat it as character data ??? A true Base64 encoding function would be: Create a byte array which is of an appropriate size, then populate it by taking each pair of characters in turn and using Byte.Parse with the number style of HexNumber. http://bytes.com/topic/c-sharp/answers/234105-base64-encode-characters-127-a Base64 encoding turns 3 bytes into 4? http://bytes.com/topic/c-sharp/answers/224907-base64-string-byte-array-whats-length-ratio