How to get a cipher of Blowfish/ECB/NoPadding using BouncyCastle in c#?

284 Views Asked by At

I would like to use BouncyCastle and decrypt a text using Blowfish/ECB/NoPadding, I can create a Blowfish engine using:

BlowfishEngine engine = new BlowfishEngine();

But after that I'm not sure how to create a cypher to decrypt using ECB and NoPadding. I also tried to use:

WrapperUtilities.GetWrapper("Blowfish/ECB/NoPadding")

But then I can't use cipher.doFinal like I would do with a Cipher

How can I do it?

1

There are 1 best solutions below

0
Peter Dettman On

It would be CipherUtilities.GetCipher("Blowfish/ECB/NoPadding") rather than WrapperUtilities. Since it's ECB/NoPadding, it would amount to wrapping BlowfishEngine with a BufferedBlockCipher (i.e. new BufferedBlockCipher(engine)). This really only adds buffering. Since there's no padding the data will have to be block-aligned. If you are receiving the input one block at a time (or have it all in an array already), it might be simpler to just use BlowfishEngine directly (i.e. as an IBlockCipher).