0

I have a .NET Framework class library that I am trying to upgrade to .NET Standard 2.0. There is a simple encryption helper that uses SqlMembershipProvider. This is being used to Encrypt and Decrypt Byte arrays. As I understand it, this provider uses the machineKey entry and the associated validationKey and decryptionKey. The code is:

public class Encryption : SqlMembershipProvider
{
    public new Byte[] EncryptPassword(Byte[] password)
    {
        return base.EncryptPassword(password);
    }

    public new Byte[] DecryptPassword(Byte[] encryptedPassword)
    {
        return base.DecryptPassword(encryptedPassword);
    }
}

SqlMembershipProvider is not available in .NET Standard. How can I port this code to .NET Standard 2.0 and still be able to decrypt strings created this way?

ProfNimrod
  • 4,142
  • 2
  • 35
  • 54
  • `SqlMembershipProvider` is part of ASP.NET 4.x. Thus, this class library binds itself to .NET Framework only. Why do you need to move it to .NET Standard, while it can only serve ASP.NET 4.x? – Lex Li Oct 14 '18 at 01:03
  • I don't need to move it specifically - I need to have the equivalent encryption functionality in .NET Standard, so I can decrypt strings created this way. – ProfNimrod Oct 14 '18 at 01:17
  • Though more than two years old, this thread is still relevant, https://stackoverflow.com/questions/38795103/encrypt-string-in-net-core – Lex Li Oct 14 '18 at 01:37
  • Thanks - I read this first, but it is not clear to me that the equivalent encryption is being used, and what role validationKey and decryptionKey in the machineKey play. – ProfNimrod Oct 14 '18 at 02:22
  • The source for SqlMembershipProvider is https://referencesource.microsoft.com/#System.Web/Security/SQLMembershipProvider.cs. The encrypt/decrypt seems to depend on System.Web.Security, which, again, is not available in .NET Standard – ProfNimrod Oct 14 '18 at 02:38

0 Answers0