C# Program to Illustrate User Authentication Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report To illustrate User Authentication using C#, We will go through the Sign-Up and login functionality. Firstly the user needs to make an account (Sign UP) and then the user can go to the login activity. Below are the steps for User Authentication. Steps For User Authentication:Step 1: START Step 2: Take user details like name, username, and password. Step 3: Verify Password with constraint. Password Length must be greater than or equal to 8 characters.Password should be made up of alphanumeric characters and at least 1 special symbol.Password Should not be more than 16 characters.Step 4: If Step 4 is successful then show the message Account Created else repeat Step 2 and Step 3 until Step 3 does not return Successful. Step 5: Take login credentials and verify if it correct or not. if credentials are Correct: Show Logged in Successfully. else show Entered wrong Username Or Password.Step 6: STOP Example 1: C# // C# implementation of User Authentication // Include namespace system using System; using System.Text.RegularExpressions; public class GFG { public const String NAME = "GEEKSFORGEEKS"; public const String USERNAME = "GEEKS"; public const String PASSWORD = "Geeks@123"; public static bool SignUp(String name, String userName, String password) { // Verify password length if (password.Length < 8 || password.Length > 16) { Console.WriteLine("Password must be in range of 8-16 characters."); return false; } Regex regex = new Regex("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]+"); if (regex.Match(password).Value=="") { Console.WriteLine("Password must contains alphanumeric characters and atleast 1 special symbol."); return false; } return true; } public static bool Login(String userName, String password) { if (userName == USERNAME && password == PASSWORD) { return true; } Console.WriteLine("Enter Valid Username Or Password!"); return false; } public static void Main(String[] args) { // Try SignUp With Invalid Password (Length < 8) Console.WriteLine("User 1 : "); if (GFG.SignUp(NAME, USERNAME, "Geeks12")) { Console.WriteLine("Account Created Successfully."); } // Try SignUp With Invalid Password (Excluding Special Symbol) Console.WriteLine("User 2 : "); if (GFG.SignUp(NAME, USERNAME, "Geeks123")) { Console.WriteLine("Account Created Successfully."); } // With Valid Password Console.WriteLine("User 3 : "); if (GFG.SignUp(NAME, USERNAME, PASSWORD)) { Console.WriteLine("Account Created Successfully."); } // With Wrong Username Or Password Console.WriteLine("User 2 : "); if (GFG.Login(USERNAME, "Geeks123")) { Console.WriteLine("Log In Successful."); } // With Valid Username And Password Console.WriteLine("User 3 : "); if (GFG.Login(USERNAME, PASSWORD)) { Console.WriteLine("Log In Successful."); } } } Output : Comment More infoAdvertise with us Next Article What is User Authentication, and Why is it Important? A aadityapburujwale Follow Improve Article Tags : C# CSharp-programs Similar Reads Authentication in Distributed System Authentication in distributed systems is crucial for verifying the identity of users, devices, and services to ensure secure access to resources. As systems span multiple servers and locations, robust authentication mechanisms prevent unauthorized access and data breaches. This article explores vari 11 min read What is User Authentication, and Why is it Important? Today when more and more companies and organizations are going digital, the security of data and authorization to important systems and services is crucial. User authentication is central to this security paradigm as it refers to the mechanism by which the identity of a user is first confirmed befor 8 min read C++ Program to Print Your Own Name Printing your own name means displaying your name on the computer screen. In this article, we will learn how to print your own name using a C++ program.ExamplesInput: name = "Anmol"Output: AnmolExplanation: Given name is printed on the output screen.Input: name = "Alex"Output: AlexExplanation: Given 3 min read Designing Authentication System | System Design Keeping your important digital information safe is like building a strong foundation, and the key to that is a good security system. This article will help you understand how to make a robust security system step by step. We'll start with figuring out what you want to protect and what you want to ac 10 min read How to Run C program in Ubuntu Learning to run a C program in Ubuntu is a great first step for anyone starting their programming journey or switching to a Linux-based system. Ubuntu offers a clean and powerful environment to write, compile, and execute C code all from the terminal.In C, this guide will show you how to get started 4 min read R Program to Generate a Random Password Password generation is a common task in programming languages. It is required for security applications and various accounts managing systems. A random password is not easily guessable which also improves the security of the accounts systems with the aim to protect information. In R Programming Lang 4 min read Like