rnapier/RNCryptor — pull request #56 by guysung (2013-03-02 03:25:09+00:00)
Title: decrypt.php initial implementation.

Hi Rob,

I've finally made the first version of the decrypt.php through a lot of research and tests.

I am using the CPCryptController for encrypting in iOS side.
(https://github.com/iosptl/ios6ptl/blob/master/ch15/CryptPic/CryptPic/RNCryptManager.m)

Corresponding encrypting codes in iOS to use the decrypt.php.
```objective-c
// Corresponding iOS encrypt codes example.
// Use the CPCryptController from https://github.com/iosptl/ios6ptl/blob/master/ch15/CryptPic/CryptPic/RNCryptManager.m
if (! [[CPCryptController sharedController] encryptData:srcData password:kRNCryptorPasswd error:&error] ) {
NSLog(@"Could not encrypt data: %@", error);
}

// Do Base64 encoding for AES128 encrypted data
NSString *saltBase64 = [[CPCryptController sharedController].salt base64EncodedString];
NSString *HMACSaltBase64 = [[CPCryptController sharedController].HMACSalt base64EncodedString];
NSString *ivBase64 = [[CPCryptController sharedController].iv base64EncodedString];
NSString *encryptedDataBase64 = [[CPCryptController sharedController].encryptedData base64EncodedString];
NSString *HMACBase64 = [[CPCryptController sharedController].HMAC base64EncodedString];

// Build the final format
NSString *encryptedDataBase64Final = [NSString stringWithFormat:@"%@%@%@%@%@",saltBase64, HMACSaltBase64, ivBase64, encryptedDataBase64, HMACBase64];
DebugLog(@"encryptedDataBase64Final: %@",encryptedDataBase64Final );

//If no error we send the post, voila!
if (!error) {

NSMutableDictionary *params = [[NSMutableDictionary alloc] init];

// Post enctypted
[params setObject:encryptedDataBase64Final forKey:@"JASON_Enc_Base64"];

// Do Post!
[[RKClient sharedClient] post:postResourcePath params:params delegate:self];

}
```

I hope this help.
Thanks.