SSCrypto / OpenSSL in C # Crypto

Someone could use the SSCrypto Framework for Cocoa to encrypt text and then decrypt it in C # /. NET? Or can someone offer some kind of guidance?

I am sure that my problem is related to the correct setting of cryptography settings, but I am not sure about using Cocoa, so I can’t say what settings are used in the library. However, my attempt to decrypt it looks like md5 hashing, CBC mode, padding with zeros and I have no idea if IV is installed or not ...

My C # code is as follows:

        public static string Decrypt( string toDecrypt, string key, bool useHashing )
    {
        byte[] keyArray;
        byte[] toEncryptArray = Convert.FromBase64String( toDecrypt );

        if( useHashing )
        {
            MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
            keyArray = hashmd5.ComputeHash( UTF8Encoding.UTF8.GetBytes( key ) );
            hashmd5.Clear();
        }
        else
            keyArray = UTF8Encoding.UTF8.GetBytes( key );

        TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
        tdes.Key = keyArray;
        tdes.Mode = CipherMode.CBC;
        tdes.Padding = PaddingMode.Zeros;

        ICryptoTransform cTransform = tdes.CreateDecryptor();
        byte[] resultArray = cTransform.TransformFinalBlock( toEncryptArray, 0, toEncryptArray.Length );

        tdes.Clear();

        return UTF8Encoding.UTF8.GetString( resultArray );
    }

When I run the encryption on the Cocoa side, I get the encrypted text:

UMldOZh8sBnHAbfN6E / 9KfS1VyWAa7RN

but it will not decrypt on the C # side with the same key.

Any help is appreciated, thanks.

+3
6

OpenSSL # OpenSSL.NET wrapper!

+2

, :

1- , . , , ASCII UTF8? binhex?

2- IV ( ) . IV, , Cocoa.

+1

IIRC, OpenSSL , MS PKCS7 ( OpenSSL PKCS5, , , ).

0

Mac - . , Cocoa, -, , PowerPC Mac.

0

, - ,

Array.Reverse .

var reversedArr = Array.Reverse(toEncrytArray)
byte[] resultArray = cTransform.TransformFinalBlock( reversedArr, 0, reversedArr.Length );
0

Cocoa, .

, , :

PyPqLI/d18Q = (base64) iv "97737D09E48B0202" (hex). "97737D09E48B" PKCS7. .NET, PaddingMode.PKCS7 , Cocoa.

0

All Articles