Link to home
Start Free TrialLog in
Avatar of AdawiAdawi
AdawiAdawiFlag for Jordan

asked on

Objective-C Decrepit Data from .Net Application

Hello Experts,

I have data come from .Net Application Via XML format, this Data had been encrypted via .Net function and it must send to IPAD application as it encrypted , I need to know how I can Decrepit this data from Objective-C

The .Net Encryption  Function will be like this

Private key() As Byte = {&H61, &H72, &H84, &H7A, &H24, &H43, &H65, &H64, &H73, &H55, &H64, &H75, &H66}



    Const PASSWORD As String = "TestPassword"

Public Function Encrypt(ByVal sPlainText As String)



        Dim aPlainBytes As Byte()

        Dim aPassword As PasswordDeriveBytes



        aPlainBytes = System.Text.Encoding.Unicode.GetBytes(sPlainText)

        aPassword = New PasswordDeriveBytes(PASSWORD, key)

        Dim sEncryptedData As Byte() = Encrypt(aPlainBytes, aPassword.GetBytes(32), aPassword.GetBytes(16))



        Return Convert.ToBase64String(sEncryptedData)



    End Function



 Private Function Encrypt(ByVal sPlainData As Byte(), ByVal aKey As Byte(), ByVal aIV As Byte()) As Byte()



        Dim oMemoryStream As MemoryStream = New MemoryStream



        Dim oRijndael As Rijndael = Rijndael.Create()

        oRijndael.Key = aKey

        oRijndael.IV = aIV



        Dim oCryptoStream As CryptoStream = New CryptoStream(oMemoryStream, oRijndael.CreateEncryptor(), CryptoStreamMode.Write)

        oCryptoStream.Write(sPlainData, 0, sPlainData.Length)

        oCryptoStream.Close()

        Dim aEncryptedData As Byte() = oMemoryStream.ToArray()



        Return aEncryptedData



    End Function

Open in new window


Help me Please
ASKER CERTIFIED SOLUTION
Avatar of darbid73
darbid73
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AdawiAdawi

ASKER

I will try it and let you know :)
I have another Question follow me :)
I have the same Issue but now with SQL server , I want to Create a code with SQL server to use the same algorithm

Help Please :)