Question: I'm working on an ASP.NET project, and i want to create and use my own authorization and authentication system to manage users (in a sql server database) like login, check authorization, and check authentication, i know in ASP.NET we have `Identity` but I want to create my own system.

so my question is do anyone have a good algorithm or a structure or just and idea for a custom system ?

Massive thanks in advance.

Answer: 
You can start from simple things, creating a model of **User** with ordinary fields **Login**, **Password**, and **AuthController** that will have two methods **RegisterUser** and **SignIn**.

**RegisterUser** - here you have to check if Login already exists, if not - insert data to table **Users**. Important thing - you have to choose algorithm to encrypt user password and save it in DB.

**SignIn** - method that will also check if user by Login and Password exists in DB (encrypt password from request by your algorithm and check if exists the same in Users table), if he is - you have to create a token and return it in response (to give an access to your portal).

Actually we can attach to it validation to a models (see <https://fluentvalidation.net/>), restore password logic with email notification and so on. A lot of examples with custom features of authorization and authentication you can find in the internet. Just separate your functionality into parts and google it.
You could fork from Identity Server 4 and create your own implementation. They have a good base to build a solution from and has integration with many app types using OpenID and OAuth. <https://identityserver4.readthedocs.io/en/latest/>