objective c - object-c and C# 3DES Encryption with different output -
I have the following problem, I would like to send my string encrypted on my webserver and decrypt it there. But when I was encrypted with Object-C, someone could tell me what I am doing.
My encryption with Object-C:
+ (NSString *) Ankriptdeta: (Ansdita *) Inputdeta {Ansdita * key = [ "" Feljedblyuesan + Yueibi 9+ JackDNPQQI "Data Using Encoding: NSTF 8 String Encoding]; NSMutableData * Output Data = [NSMutableData DataWithLath: (inputData.length + kCCBlockSize3DES)] ;; Size_t outLength; CCCryptorStatus Results = CCCrypt (kCCEncrypt, // CCOperation op kCCAlgorithm3DES, // CCAlgorithm alg KCCOptionPKCS7Padding, // CCOptions options key.bytes, // constants zero * key key.length, // size_t k eyLength null, // const void * iv inputData .bytes, // const void * dataInputData.length, // size_t Detailendaput Autputdeta.amayutiblbaits, // void * data out Autputdetaklambi, // Akar_ti Detaoaf and landline); / / size_t * Detaotomowdः (result! = KCCSuccess) return null; [Autputdeta Setlambi: Autlenth]; NSString * output string = [Autputdeta base64EncodingWithLineLength: 0]; return output string;} C # My encryption with:
public stream Encrypt (encrypt string) {string retValue = ""; Try {byte [key]; Byte [] toEncryptArray = UTF8Encoding.UTF8.GetBytes (toEncrypt); KeyArray = UTF8Encoding.UTF8.GetBytes ("FeljWsN + uaEB9 + jqDnPRQeIi"); TripleDispicious Service ProviderTdes = New TripleDryScript Service Provider (); Tdes.Key = keyArray; Tdes.Mode = CipherMode.ecb; Tdes.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = tdes.CreateEncryptor (); Byte [] ResultsAre = cTransform.TransformFinalBlock (toEncryptArray, 0, toEncryptArray.Length); RetValue = Convert ToBase64String (Resultant, 0, ResultantRecord); } Hold {} return retValue; } Object-C:
Ansdita * _secretData = [[ "" Christian "Detauputing Encoding Ansutif 8 string encoding]; NSString * encrypted string = [Triple allows DES Ankriptdeta: _secretData]; I "Lp3x2fm2jrK1ftsHoZN9cg ==" and C #
encryption Ankripshnsat = new encryption (); string encrypted String = EncryptionSet. Encrypt ("Cristian"); I "Lp3x2fm2jrJ7ghY9SXRlUw =="
gives the need to add KCC opaction behind PKCS7 padding "| kCCOptionECBMode ":
CCCryptorStatus result = CCCrypt (kCCEncrypt, // kCCAlgorithm3DES from CCOperation, // CCAlgorithm alg kCCOptionPKCS7Padding | kCCOptionECBMode, // CCOptions option key.bytes, // const void * key key. Length, // size_t keyLength zero, // constellation zero * iv inputData.bytes, // constants zero * dataIn inputData.length, // dataInLength outputData.mutableBytes size_t, // zero * dataOut outputData.length, // size_t dataoff available And out length;); // size_t * Data Automomed Note: this was removed from the question and posted on behalf of OP.
Comments
Post a Comment