What is the best way to implement BlowFish ECB encryption in iOS???
I have been googling a lot and found the library here. But there are no documentation of this library. Not sure how to use it.
What is the best way to implement BlowFish ECB encryption in iOS ??? I
Share
I got Paul Kocher implementation from Bruce Schneier’s website. And here is how an encryption method may look like:
I am not really good in C, but it seems that my implementation works correctly. To decrypt you need just repeat same steps, but instead of Blowfish_Encrypt you need to call Blowfish_Decrypt.
Here is a source code for that (I assume that you just decrypt the cipher text, but don’t deal with padding here):
You might want to return pure bytes or Base64 string. For the last case I have a category, which adds an initialiser, which initialises NSData object with Base64 string and a method, which allows to get Base64 string from NSData.
You should also think about playing with PADDING_PHRASE, for example, what if you want to add not just several spaces, but some random bytes? In this case you should send a padding length somehow.
Update: Actually, you should not use PADDING_PRASE in your process. Instead, you should use one of the standard algorithms for block ciphers described on Wikipedia page