I am recieving the Encrypted data by server (BLOWFISH ALGORITHM) , I have to decrypt it by using blowfish algorithm in IOS.
you can donwload my code from here : https://www.dropbox.com/s/nswsm7des7isgd5/BlowfishTest-4.zip
I am struggling from 2 days with this task , I try lot of links and find few useful :
- Blowfish Source code
- How to implement Blowfish algorithm in iOS
- http://www.codeding.com/articles/blowfish-encryption-algorithm-for-iphone
In third link, i got ECB ( I have to decrypt using ECB). but this code also not gives correct output after decryption.
I am using a online tool for testing and this shows correct output : http://www.tools4noobs.com/online_tools/decrypt/
Key = 20zE1E47BE57$51
Input value is = aed5c110d793f850521a4dd3a56a70d9
Algorithm = BLOWFISH
Mode = ECB
Decode the input using= Hexa
output = aYzY1380188405 ( this is correct output which i want)
and I am getting : ¹àÀhÒ¢º¹iÂF
Here is my code :
//Mode selected by default in nib: “ECB”
NSString *modeString = [encryptionModeControl titleForSegmentAtIndex:encryptionModeControl.selectedSegmentIndex];
BlowfishAlgorithm *blowFish = [BlowfishAlgorithm new];
[blowFish setMode:[BlowfishAlgorithm buildModeEnum:modeString]];
[blowFish setKey:key];
[blowFish setInitVector:initVector];
[blowFish setupKey];
NSString *cipherText = cipherTextView.text;
NSString *plainText = [blowFish decrypt:cipherText];
NSLog(@"cipher-text: %@", cipherText);
NSLog(@"plain-text: %@", plainText);
Note : Server side data is Encrypted using BLOWFISH in ECB mode, and converted to hexadecimal notation.