cureos / shim

Shim expands the ability to create Portable Class Libraries by providing reduced or dummy implementations of .NET Framework classes that are not represented in PCL.
https://www.nuget.org/packages/shim
GNU Lesser General Public License v3.0
27 stars 6 forks source link

System.Cryptography #48

Open ncruces opened 8 years ago

ncruces commented 8 years ago

I'd like to extend System.Cryptography to support this:

using (var md5 = MD5.Create())
{
    hash = md5.ComputeHash(input);
}

However, I'm unsure if all current shim platforms have MD5 support (either through a System.Cryptography forward, or a simple enough API that doesn't mean implementing it from scratch). MD5 is just one example, I'd do SHA1 at least as well.

Before I go through it, though I'd like to know if you think it's a good idea, if an implementation that only works on a (hopefully large) subset of platforms has any chance of being accepted, etc.

Currently, I have working managed code (lifted from Mono) in my PCLs, so a change with zero chances of getting upstreamed to the official Nuget package is of very little use to me.

I'd still like to contribute something back, if it helps others.

anders9ustafsson commented 8 years ago

@ncruces I am very sorry, I thought I answered this several days ago, but my answer seems to never have been posted?

Anyway, I think this is a good idea in principle. I have not checked how large the subset of supporting platforms is, though? For modern Windows/WPA/UWP, the API is substantially different for example.

Do you consider PCLCrypto an alternative?

ncruces commented 8 years ago

I did consider PCLCrypto. However, the dependency tree frightened me. Also, PCLCrypto tends to follow the WinRT API for most things, which I find less than ideal until that API gains more traction. I tend to use Shim to, as you put it, "expand the ability to create Portable Class Libraries from legacy code".

My biggest unknown is precisely whether I can support WPA/UWP/etc without putting over your shoulders the burden of supporting (e.g) a managed MD5 implementation. Silverlight doesn't seem to have any MD5 implementation at all.