C# Program to Illustrate User Authentication - GeeksforGeeks (2024)

// 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.");

}

}

}

C# Program to Illustrate User Authentication - GeeksforGeeks (2024)
Top Articles
FIDO2 – de meest geavanceerde 2FA methode - Cryptocursus-info.nl
Beleggingsupdate maart 2021: Crypto stijgt als een gek!
Craigslist Livingston Montana
Printable Whoville Houses Clipart
Canya 7 Drawer Dresser
Thor Majestic 23A Floor Plan
Le Blanc Los Cabos - Los Cabos – Le Blanc Spa Resort Adults-Only All Inclusive
Maria Dolores Franziska Kolowrat Krakowská
Google Jobs Denver
Georgia Vehicle Registration Fees Calculator
Arrests reported by Yuba County Sheriff
Nordstrom Rack Glendale Photos
Tanger Outlets Sevierville Directory Map
Wmlink/Sspr
Ukraine-Russia war: Latest updates
Regal Stone Pokemon Gaia
Morocco Forum Tripadvisor
Babyrainbow Private
Rosemary Beach, Panama City Beach, FL Real Estate & Homes for Sale | realtor.com®
Binghamton Ny Cars Craigslist
Jinx Chapter 24: Release Date, Spoilers & Where To Read - OtakuKart
Georgia Vehicle Registration Fees Calculator
Charter Spectrum Store
Roof Top Snipers Unblocked
Johnnie Walker Double Black Costco
Kcwi Tv Schedule
Empire Visionworks The Crossings Clifton Park Photos
Why do rebates take so long to process?
Watch Your Lie in April English Sub/Dub online Free on HiAnime.to
Macu Heloc Rate
Downtown Dispensary Promo Code
Albertville Memorial Funeral Home Obituaries
Shoe Station Store Locator
Bursar.okstate.edu
Kaiserhrconnect
Here’s how you can get a foot detox at home!
Linabelfiore Of
Today's Final Jeopardy Clue
Weapons Storehouse Nyt Crossword
Sam's Club Gas Prices Florence Sc
Tsbarbiespanishxxl
Pekin Soccer Tournament
Satucket Lectionary
How Big Is 776 000 Acres On A Map
FedEx Authorized ShipCenter - Edouard Pack And Ship at Cape Coral, FL - 2301 Del Prado Blvd Ste 690 33990
Craigslist Binghamton Cars And Trucks By Owner
Best Suv In 2010
Dietary Extras Given Crossword Clue
Freightliner Cascadia Clutch Replacement Cost
Ty Glass Sentenced
Craigslist Charlestown Indiana
Https://Eaxcis.allstate.com
Latest Posts
Article information

Author: Saturnina Altenwerth DVM

Last Updated:

Views: 6037

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Saturnina Altenwerth DVM

Birthday: 1992-08-21

Address: Apt. 237 662 Haag Mills, East Verenaport, MO 57071-5493

Phone: +331850833384

Job: District Real-Estate Architect

Hobby: Skateboarding, Taxidermy, Air sports, Painting, Knife making, Letterboxing, Inline skating

Introduction: My name is Saturnina Altenwerth DVM, I am a witty, perfect, combative, beautiful, determined, fancy, determined person who loves writing and wants to share my knowledge and understanding with you.