View the step-by-step solution to:

Question

Input validation is one of the main things you can do to prevent a variety of different types of attacks. C#

program that accepts an e-mail address and a password as input and validates it using the following methods (Please note, this is not all-inclusive.):

For the E-Mail Address:

Best practice for validating an email address:

  • It is case sensitive in the local portion of the address (left of the rightmost @ character)
  • Has non-alphanumeric characters in the local-part (including + and @)
  • Has zero or more labels
  • Check for presence of at least one @ symbol in the address

For Passwords:

You will need to make sure that all passwords meet the company's criteria.

  • Data Type validation
  • Format validation
  • That the password has at least 10 characters, 1 upper case, 1 lower case, 1 number between 1 and 20.
  • That it doesn't use semicolons or quotes.




PART OF THE CODE IS LISTED BELOW:


using System;

using System.Net.Mail;

using System.Linq;

using System.Collections.Generic;

namespace EmailVerifier

{

class Program

{

static void ValidateEmail(string emailAddress)

{

Console.WriteLine("Hello and welcome to the email address verifier");

Console.WriteLine("When prompter, please enter your email address for verification");

Console.WriteLine("The program will then verify the address.");

   

   try {

       MailAddress testmail = new MailAddress (emailAddress);

       

   }

   

   catch(ArgumentNullException ex) {

       Console.WriteLine("nnAddress is null!: " + ex.Message + "n");

   }

   catch(ArgumentException ex) {

       Console.WriteLine("nnAddress is emty!: " + ex.Message + "n");

   }

   catch(FormatException ex) {

       Console.WriteLine("nnAddress is not in the correct format!: " + ex.Message + "n");

   }

   catch {

       Console.WriteLine("nnEmail is verified!");

   }

                         


}

}

}

Top Answer

Sample Output: - First Run- Hello and welcome to the email address verifier Enter the email id user.user.com Address is not... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question