c# - AES file encryption with .Net Framework and decrypt it with IOS -


we encrypt pdfs using aesmanaged algorithm implemented in .net framework. used example explained in here implement c# code encrypt file. need decrypt file using iphone application.(that requirement). use this code decryption failed returning error.

'error domain=commoncryptoerrordomain code=-4304 "decode error" userinfo=0x127356c0 {nslocalizedfailurereason=input data did not decode or decrypt correctly, nslocalizeddescription=decode error'

can 1 me resolve issue.

we use 12345678 encryption key.

share|improve question
    
so error returns? – nickolay olshevsky may 6 '13 @ 11:56
    
it says 'error domain=commoncryptoerrordomain code=-4304 "decode error" userinfo=0x127356c0 {nslocalizedfailurereason=input data did not decode or decrypt correctly, nslocalizeddescription=decode error' – nath may 6 '13 @ 12:17
    
@ganuke don't post important information comment. please edit question , add error. – duncan jones may 6 '13 @ 12:47
    
you can't use 12345678 encryption key. aes takes 16, 24 or 32 byte sequence, string. – codesinchaos may 6 '13 @ 15:58
    
i found this , able integrate in our system. every one – nath may 14 '13 @ 9:40

most problem in deriving actual key password (12345678 cannot aes key directly - 8 bytes).

share|improve answer

technically should work though i've never tested it, both methods uses same ad-hoc format.

encrypt using authenticated encryption example.

//use secret data want encrypt instead. string secretmessage = "message";  var rncryptorheader = new byte[]{                             2, //rncryptor format version 2                             0  //rncryptor uses password                         };  //encryptedstring base64 encoded var encryptedstring = aesthenhmac.simpleencryptwithpassword(secretmessage,                                                              password:"1234567891011",                                                                   nonsecretpayload:rncryptorheader); 

then decrypt using rncryptor , nsdata+base64 ios

//this encrypted data passed .net nsstring *encryptedstring = @"age8c9e7gsfyoamsotiogylq0o6mdcumxxjn/iza3azym4kvwzakfykip6mqmt/qkpfftdb3xqhmkoxtqem+ra0ihxovzinlma2kjtg6bonmlg==";  nsdata *encrypteddata = [nsdata datafrombase64string: encryptedstring]; nserror *error; nsdata *decrypteddata = [rndecryptor decryptdata:encrypteddata                                     withpassword:@"1234567891011"                                            error:&error]; nsstring *secretmessage = [[[nsstring alloc] initwithdata:decrypteddata                                                  encoding:nsutf8stringencoding] autorelease]; 

since aren't dealing strings , dealing bytes directly, remove base64 , utf8 encoding/decoding objective-c example , linked c# example, once sure working.

share|improve answer

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments