Jano
Jano

Reputation: 307

Store a password on .Net Core like ASP.Net WebSecurity

we have a application developed on asp.net. It uses membership provider with its websecurity functionality to register accounts and log users.

We have another application which needs to share the same database. This one is developed on asp.Net Core. It does not require a login but it needs to register accounts on membership provider format.

As both systems are not compatible, we want to write the passwords manually on the table webpages_Membership.

Is it possible to store passwords, on the .Net Core application, using the same salt+hash that is used on the ASP.Net application?

If not, there is any way to solve it?

The only solution I see is to create our own login system, in our tables, and adapt our ASP.Net application to this purpose; but in this case it is a lot of work and I'd prefer to find another solution.

Thanks

Upvotes: 1

Views: 390

Answers (1)

plainionist
plainionist

Reputation: 3573

Maybe you can just use System.Security.SecureString from both applications and so ensure that the database values are compatible?

You could use code like this to convert the user entered string into a SecureString

    public static SecureString ToSecureString( this string source )
    {
        if ( source == null )
        {
            return null;
        }

        var securePassword = new SecureString();

        foreach ( char c in source )
        {
            securePassword.AppendChar( c );
        }

        securePassword.MakeReadOnly();

        return securePassword;
    }

Upvotes: 1

Related Questions