Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use the C# code provided below, to provide the following information: Add one more customer with your name and fake password and credit card

Please use the C# code provided below, to provide the following information:

Add one more customer with your name and fake password and credit card information.

Run the program.

Save or memorize the password you provided.

Observe the XML file created in the same folder, take a screenshot.

Observe in the .csproj file the library this App refers to.

Update that library to 100000 iterations, update the salt to any word of your choice of about the same size as current salt.

Change your Exercise02 code to store result into protected-customers2.xml.

Run the code using the same password.

Compare created XMLs. Write a short summary of this comparison. Provide screenshot of XML files

using System.Collections.Generic;

using System.IO;

using System.Xml;

using Packt.Shared;

using static System.Console;

using static System.IO.Path;

using static System.Environment;

namespace Exercise02

{

class Program

{

static void Main(string[] args)

{

WriteLine("You must enter a password to encrypt the sensitive data in the document.");

WriteLine("You must enter the same passord to decrypt the document later.");

Write("Password: ");

string password = ReadLine();

// define two example customers and

// note they have the same password

var customers = new List

{

new Customer

{

Name = "Bob Smith",

CreditCard = "1234-5678-9012-3456",

Password = "Pa$$w0rd",

},

new Customer

{

Name = "Leslie Knope",

CreditCard = "8002-5265-3400-2511",

Password = "Pa$$w0rd",

}

};

// define an XML file to write to

string xmlFile = Combine(CurrentDirectory,

"..", "protected-customers.xml");

var xmlWriter = XmlWriter.Create(xmlFile,

new XmlWriterSettings { Indent = true });

xmlWriter.WriteStartDocument();

xmlWriter.WriteStartElement("customers");

foreach (var customer in customers)

{

xmlWriter.WriteStartElement("customer");

xmlWriter.WriteElementString("name", customer.Name);

// to protect the credit card number we must encrypt it

xmlWriter.WriteElementString("creditcard",

Protector.Encrypt(customer.CreditCard, password));

// to protect the password we must salt and hash it

// and we must store the random salt used

var user = Protector.Register(customer.Name, customer.Password);

xmlWriter.WriteElementString("password", user.SaltedHashedPassword);

xmlWriter.WriteElementString("salt", user.Salt);

xmlWriter.WriteEndElement();

}

xmlWriter.WriteEndElement();

xmlWriter.WriteEndDocument();

xmlWriter.Close();

WriteLine();

WriteLine("Contents of the protected file:");

WriteLine();

WriteLine(File.ReadAllText(xmlFile));

}

}

}

REFERENCE CODE:

namespace Packt.Shared

{

public class Customer

{

public string Name { get; set; }

public string CreditCard { get; set; }

public string Password { get; set; }

public string Salt { get; set; }

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

What are the objectives of job evaluation ?

Answered: 1 week ago

Question

Write a note on job design.

Answered: 1 week ago

Question

Compute the derivative of f(x)cos(-4/5x)

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago