Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $keyT = "keyString";
- $key = md5($key);
- $key_size = strlen($key);
- $plaintext = "Text_Block";
- $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
- $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key,
- $plaintext, MCRYPT_MODE_CBC, $iv);
- # prepend the IV
- $ciphertext = $iv . $ciphertext;
- # encode using base64
- $ciphertext_base64 = base64_encode($ciphertext);
- $data = $ciphertext_base64;
- ?>
- -(void) connectionDidFinishLoading:(NSURLConnection *) connection {
- NSLog(@"Succesfully downloaded data! received %d bytes.", [downloadData length]);
- NSString *dataText = [[NSString alloc] initWithData:downloadData encoding:NSUTF8StringEncoding];
- NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:dataText options:0];
- // Now lets say I have the key created in the php file:
- char void *key = @"key goes here";
- // This is where it stops for me, how do I extract the IV (which should be the first 16 characters) and how do I use this to decrypt the data?
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement