New User?   Join Now     Login            Forgot Password?    
Browse by Category
Articles
Games
Algorithms
Software
Browse Projects
XamlQuery v1.2
YtoX
Racketbot
Browse Topics
Blowfish Algorithm for iPhone  (12361 hits)
 Share this Article
 
Posted by Prabu Arumugam on Mar-23-2013
Languages: Objective-C

This article presents the Blowfish algorithm implementation in Objective-C for use in iPhone/iPad projects. The source code is available for download below and you can readily include the header and objective-C files in your iOS project. Two cipher modes are implemented in the code, namely ECB (electronic codebook) and CBC (cypher-block chaining).

What is Blowfish Algorithm?

Blowfish is a keyed symmetric block encryption algorithm, designed by Bruce Schneier. The word 'symmetric' means that it uses the same secret 'key' to encrypt as well as decrypt the messages. The word 'block cipher' means that it divides the input message into fixed-length blocks during the encryption/decryption process. The block-length for Blowfish is 8 bytes i.e. 64 bits, and the key length can be upto a maximum of 56 bytes i.e. 448 bits.

Blowfish algorithm has been claimed as reasonably strong and looks like no effective cryptanalysis has been found so far. It is an ideal algorithm for use in resource-constrained environments like embedded systems. The author of Blowfish has stated that the algorithm will remain unpatented and will be available in public domain and can be freely used by anyone. More information on Blowfish is available at http://en.wikipedia.org/wiki/Blowfish_(cipher)

The following image shows the iPhone test application for Blowfish encryption/decryption.

The following image shows the Xcode screenshot of the iPhone test application. The image shows the header and objective-c files available for using in your iPhone application.

Using the code

The following code shows the event-handler of the 'Encrypt' button . The code shows how to use the BlowfishAlgorithm Objective-C class for encrypting a user-specified plain text. You can provide a random key and initialization-vector. The key can be 1 to 56 bytes in length and the init-vector should be 8 bytes in length.


 Downloads for this article
File Language Tools
Blowfish-ObjectiveC-Source  47.39 kb  (290 downloads) Objective C iOS SDK 4.3, Xcode 4.6

 Share this Article

 Comments on this Article
Comment by tomatoman95 on Aug-08-2013
Is it possible if you can post the equivalent php code?
 Post your comment here
Your Name
Your Email
Comment
Post Comment

About About      Terms Terms      Contact Contact
codeding on Facebook Facebook      codeding on Twitter Twitter