Search code examples
iosxamarin.ioscryptographyxamarincommoncrypto

Where is the class CryptoCommon in xamarin


Im trying to use the CryptoCommon class but unable the find it in the monotuch assembly.

I found the assembly Mono.Security.Cryptography, does it have the same performance as the CryptoCommon class?

Thanks!!


Solution

  • CommonCrypto is used internally inside Xamarin.iOS, this is not something extra - i.e. there's no need to opt-in or opt-out.

    What it means is that it's use is totally transparent to your code. If an algorithm is available in CommonCrypto then using the classic .NET type will use it.

    E.g.

    // this will use CommonCrypto. AES is supported by CommonCrypto
    // if your device supports it AES can be hardware accelerated
    var aes = Aes.Create (); 
    
    // this will also use CommonCrypto. SHA-1 is supported by CommonCrypto
    // if your device supports it SHA-1 can be hardware accelerated
    var sha = new SHA1Managed (); 
    
    // this will not use CommonCrypto since the algorithm is not supported by Apple
    var r = RIPEMD160.Create (); 
    

    More information about CommonCrypto can be found on my blog.