PROJECT
Design Website For Shopping Using [Link] (C#) And Encrypt Personal Information Using RSA Algorithm
Completed by Firas M. Kadhum
Iraq - Baghdad
Description:
This project illustrates a very simple website for sell different types of mobile devices by request. So in short, after the customer fills all information to complete purchasing procedure, he/she will receive confirmation message which contains the most of information that have been entered, moreover, the encrypted information using RSA Algorithm to his /her e-mail that has already been entered in buy page. Figures and the script code show the project is fully.
The Figures:
Fig 1: Master Page (with Default Page)
Fig 2: About Page
Fig 3: Buy Page
3
Fig 4: Buy Page during the filling
Fig 5: Buy Page after confirm purchase
4
Fig 6: Confirmation Message
Fig 6: Contact Us Page
5
Fig7: Contact Us Page during the filling
The Code [Link] (C#):
Default Pages Code: using using using using using using System; [Link]; [Link]; [Link]; [Link]; [Link];
public partial class _Default : [Link] { protected void Page_Load(object sender, EventArgs e) { } protected void ButtonBuy1_Click(object sender, EventArgs e) { [Link]("Phone1", [Link]); [Link]("Price1", [Link]); // Redirect to [Link] page. [Link]("[Link]");
} protected void ButtonBuy2_Click(object sender, EventArgs e) { [Link]("Phone2", [Link]); [Link]("Price2", [Link]); // Redirect to [Link] page. [Link]("[Link]");
Contact Us Pages Code:
using using using using using using using using System; [Link]; [Link]; [Link]; [Link]; [Link]; [Link]; [Link];
public partial class ContactUs : [Link] { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { MailMessage MailMsg = new MailMessage(); [Link]("YourID@[Link]"); [Link] = new MailAddress( [Link]); [Link] = [Link]; // To send a message in multiple lines string message_c = "This is a message from the our contact page:"; [Link] = "<div style=\"font: 11px verdana, arial\">"; [Link] += message_c.Replace("\n", "<br/>")+"<br/><br/>"; [Link] += "<h3>The Message:</h3>"; [Link] += "<div style=\"font-size:11px;line-height:16px\">"; [Link] += [Link]; [Link] += "<hr /><br />"; [Link] += "<h3>Sender information:</h3>"; [Link] += "<div style=\"font-size:11px;line-height:16px\">"; [Link] += "<strong>Name :</strong> " + [Link] + "<br />"; [Link] += "<strong>E-mail :</strong> " + [Link] + "<br />"; [Link] += "<hr /><br />"; [Link] += "<h3>Attachment:</h3>"; [Link] += "<div style=\"font-size:11px;line-height:16px\">"; [Link] = true; // To upload file if ( [Link]) { [Link](new Attachment([Link], [Link])); } SmtpClient smtp = new SmtpClient(); [Link] = "[Link]"; [Link] = 587; [Link] = false; [Link] = new [Link]("YourID@[Link]","YourGmailPassword"); [Link] = true;
[Link]= true; try {
[Link](MailMsg); [Link] = " Dear " + [Link] + " , your message has been sent successfully"; [Link] = ""; [Link] = ""; [Link] = ""; [Link] = ""; } catch (Exception ex) { [Link] = [Link]; } } }
Design page:
<%@ Page Title="Contact Us" Language="C#" MasterPageFile="~/[Link]" AutoEventWireup="true" CodeFile="[Link]" Inherits="ContactUs" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"> <style type="text/css"> .style46 { color: #FF0000; } .style57 { text-decoration: underline; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> <h2> Contact Us: </h2> <p><strong style="color: #0000FF; font-weight: bold"> Please,provide us your info. and message: <span class="style46"><strong style="font-weight: bold"> <span class="style57"> Note that</span>: * means required field.</strong></span></strong></p> <p> Your name:<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtYourName" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> <br /> <asp:TextBox ID="txtYourName" runat="server"></asp:TextBox><br /> Your email address:<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtYourEmail" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> <br /> <asp:TextBox ID="txtYourEmail" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtYourEmail" ErrorMessage="It must be: example@[Link]" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([.]\w+)*"></asp:RegularExpressionValidator> <br /> Subject:<br /> <asp:TextBox ID="txtSubject" runat="server"></asp:TextBox><br /> Message:<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtMessage" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> <br /> <asp:TextBox ID="txtMessage" runat="server" Height="60px" TextMode="MultiLine" Width="300px"></asp:TextBox><br /> Attachment:<br /> <asp:FileUpload ID="FileUpload1" runat="server" /><br /> <br /> <asp:Button ID="Button1" runat="server" Text="Send" ToolTip="Send Message" onclick="Button1_Click" /><br /> <asp:Label ID="LabelR" runat="server" ForeColor="#3333FF" style="font-weight: 700"></asp:Label> </p> </asp:Content>
10
Buy Pages Code:
using using using using using using using using using using System; [Link]; [Link]; [Link]; [Link]; [Link]; [Link]; [Link]; [Link]; [Link];
public partial class Buy : [Link] { protected void Page_Load(object sender, EventArgs e) { // Reads info into variables on the [Link] page. //For first phone if (Session["Phone1"] != null) { [Link] = (string)(Session["Phone1"]); [Link] = (string)(Session["Price1"]); [Link](); } //For second phone if (Session["Phone2"] != null) { [Link] = (string)(Session["Phone2"]); [Link] = (string)(Session["Price2"]); [Link](); }
protected void ButtonCancel_Click(object sender, EventArgs e) { [Link]("[Link]"); } protected void ButtonConfirmPurchase_Click(object sender, EventArgs e) { //============================================================================== // Code to Encrypt Credit Card Number using RSA Algorithm: //============================================================================== UnicodeEncoding bytConvertor = new UnicodeEncoding(); String plaintext = [Link]; // TextBox which has Credit Card Number byte[] plainData = [Link](plaintext); RSACryptoServiceProvider RSAServiceProvider = new RSACryptoServiceProvider(); byte[] enData = Encrypt(plainData, [Link](false)); String Encrypted_CreditCard_Number = [Link](enData); //============================================================================== // Code to send Confirmation Message to customer's e-mail: //============================================================================== MailMessage MailMsg = new MailMessage(); [Link]([Link]); [Link] = new MailAddress("YourID@[Link]"); [Link] = "Confirmation Message";
11
string message_c = "Thanks for your purchase."; [Link] = "<div style=\"font: 11px verdana, arial\">"; [Link] += message_c.Replace("\n", "<br/>") + "<br/><br/>"; [Link] += "<h3>Purchasing information:</h3>"; [Link] += "<div style=\"font-size:11px;line-height:16px\">"; [Link] += "<strong>Item purchased :</strong> " + [Link] + "<br />"; [Link] += "<strong>Price :</strong> " + [Link] + "<br />"; [Link] += "<strong>Name :</strong> " + [Link] +" "+ [Link] +" "+ [Link] + "<br />"; [Link] += "<strong>E-mail :</strong> " + [Link] + "<br />"; [Link] += "<strong>Country :</strong> " + [Link] + "<br />"; [Link] += "<strong>Address :</strong> " + [Link] + "," + [Link] + " " + [Link] + "," + [Link] + "<br />"; [Link] += "<strong>Mobile :</strong> " + [Link] + "<br />"; [Link] += "<hr /><br />"; [Link] += "<h3>Card information:</h3>"; [Link] += "<div style=\"font-size:11px;line-height:16px\">"; [Link] += "<strong>Credit Card Types:</strong> " + [Link] + "<br />"; [Link] += "<strong>Card holder name printed on card:</strong> " + [Link] + "<br />"; [Link] += "<strong>Credit Card Number:</strong> " + Encrypted_CreditCard_Number + "<br />"; [Link] += "<strong>Card Expiration:</strong> " + [Link] + "<br />"; [Link] += "<strong>Card Verification Code(3 digits):</strong> " + [Link] + "<br />"; [Link] = true; SmtpClient smtp = new SmtpClient(); [Link] = "[Link]"; [Link] = 587; [Link] = false; [Link] = new [Link]("YourID@[Link]", "YourGmailPassword"); [Link] = true; [Link] = true; [Link] = true; try { [Link](MailMsg); [Link] = " Thank you!" + [Link] + " " + [Link] + " " + [Link] + " ,your purchase requested has been submitted successfully"; [Link] = " Please,check your email for order [Link] may exit this page."; } catch (Exception ex) { [Link] = [Link]; }
//============================================================================== // Encrypt Method //============================================================================== static private byte[] Encrypt(byte[] DataToEncrypt, RSAParameters keyInfo) { RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(); [Link](keyInfo); return [Link](DataToEncrypt, false); } }
12
Design page:
<%@ Page Title="Buy" Language="C#" MasterPageFile="~/[Link]" AutoEventWireup="true" CodeFile="[Link]" Inherits="Buy" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> <h2> Buy: </h2> <p><strong style="color: #0000FF; font-weight: bold"> Please , provide us your information: </strong> <span class="style46"><strong style="font-weight: bold"> <span class="style57"> Note that</span>: * means required field</strong></span></p> <table class="style2"> <tr> <td class="style59"> Selected item :</td> <td class="style60"> <asp:Label ID="LabelSitem" runat="server" style="color: #0000FF; font-weight: 700"></asp:Label> </td> <td class="style61"> Price :</td> <td> <asp:Label ID="LabelPrice" runat="server" style="color: #0000FF; font-weight: 700"></asp:Label> </td> <td> </td> </tr> </table> <p> <asp:RadioButtonList ID="RBListStatus" runat="server" RepeatDirection="Horizontal"> <asp:ListItem>Mr.</asp:ListItem> <asp:ListItem>Mrs.</asp:ListItem> <asp:ListItem>Miss.</asp:ListItem> <asp:ListItem>Ms.</asp:ListItem> </asp:RadioButtonList>
<table class="style2"> <tr> <td class="style43"> First Name:</td> <td class="style20"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtFirstName" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style47"> <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox> </td> <td class="style32"> Last Name:</td> <td class="style44"> <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtLastName" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
13
</td> <td class="style22" colspan="3"> <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox> </td> <td class="style19" colspan="2"> </td> <td> </td> </tr> <tr> <td class="style43"> E-mail Address:</td> <td class="style42"> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtEmail" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style47"> <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage=" ex@[Link]" ForeColor="Red" ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([.]\w+)*"></asp:RegularExpressionValidator> </td> <td class="style32"> Country:</td> <td class="style44"> <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="DDListCountry" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style22" colspan="3"> <asp:DropDownList ID="DDListCountry" runat="server" Height="19px" Width="123px"> <asp:ListItem Selected="True"></asp:ListItem> <asp:ListItem>Afghanistan</asp:ListItem> <asp:ListItem>Albania</asp:ListItem> <asp:ListItem>Algeria</asp:ListItem> <asp:ListItem>Argentina</asp:ListItem> <asp:ListItem>Australia</asp:ListItem> <asp:ListItem>Bahrain</asp:ListItem> <asp:ListItem>Belgium</asp:ListItem> <asp:ListItem>Bolivia</asp:ListItem> <asp:ListItem>Brazil</asp:ListItem> <asp:ListItem>Cameroon</asp:ListItem> <asp:ListItem>Canada</asp:ListItem> <asp:ListItem>Chile</asp:ListItem> <asp:ListItem>China</asp:ListItem> <asp:ListItem>Egypt</asp:ListItem> <asp:ListItem>Estonia</asp:ListItem> <asp:ListItem>Finland</asp:ListItem> <asp:ListItem>France</asp:ListItem> <asp:ListItem>Georgia</asp:ListItem> <asp:ListItem>Germany</asp:ListItem> <asp:ListItem>Greece</asp:ListItem> <asp:ListItem>Haiti</asp:ListItem> <asp:ListItem>Honduras</asp:ListItem> <asp:ListItem>Hungary</asp:ListItem> <asp:ListItem>Iceland</asp:ListItem> <asp:ListItem>India</asp:ListItem> <asp:ListItem>Iraq</asp:ListItem> <asp:ListItem>Italy</asp:ListItem>
14
<asp:ListItem>Jamaica</asp:ListItem> <asp:ListItem>Japan</asp:ListItem> <asp:ListItem>Ukraine</asp:ListItem> <asp:ListItem>United Arab Emirates</asp:ListItem> <asp:ListItem>United Kingdom</asp:ListItem> <asp:ListItem>United States</asp:ListItem> <asp:ListItem>Uruguay</asp:ListItem> <asp:ListItem>Uzbekistan</asp:ListItem> <asp:ListItem>Venezuela</asp:ListItem> <asp:ListItem>Vietnam</asp:ListItem> <asp:ListItem>Yemen</asp:ListItem> <asp:ListItem>Zambia</asp:ListItem> <asp:ListItem>Zimbabwe</asp:ListItem> </asp:DropDownList> </td> <td class="style19" colspan="2"> </td> <td> </td> </tr> <tr> <td class="style43"> Address:</td> <td class="style42"> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtAddress" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style47"> <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox> </td> <td class="style32"> City:</td> <td class="style44"> <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtCity" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style29"> <asp:TextBox ID="txtCity" runat="server" style="text-align: left"></asp:TextBox> </td> <td class="style30"> State:</td> <td class="style45"> <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtState" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style27"> <asp:TextBox ID="txtState" runat="server"></asp:TextBox> </td> <td class="style26"> </td> <td> </td> </tr> <tr> <td class="style43"> Zip/Post Code:</td> <td class="style42"> <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
15
ControlToValidate="txtZPCode" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style47"> <asp:TextBox ID="txtZPCode" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtZPCode" ErrorMessage="5d or 5d-4d " ForeColor="Red" ValidationExpression="^\d{5}(-\d{4})?$"></asp:RegularExpressionValidator> </td> <td class="style32"> Mobile:</td> <td class="style18"> </td> <td class="style29"> <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox> </td> <td class="style30"> </td> <td class="style31"> </td> <td class="style27"> </td> <td class="style26"> </td> <td> </td> </tr> </table> <p> <strong>Card information:</strong></p> <table class="style2"> <tr> <td class="style58"> Credit Card Types:</td> <td class="style42" colspan="2"> <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="DDListCardTypes" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style53"> <asp:DropDownList ID="DDListCardTypes" runat="server"> <asp:ListItem Selected="True"></asp:ListItem> <asp:ListItem>MasterCard</asp:ListItem> <asp:ListItem>Visa</asp:ListItem> <asp:ListItem>Visa Electron</asp:ListItem> <asp:ListItem>China UnionPay</asp:ListItem> <asp:ListItem>Other</asp:ListItem> </asp:DropDownList> </td> <td class="style55"> Card Expiration:</td> <td class="style44"> <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="txtCardEx" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style48"> <asp:TextBox ID="txtCardEx" runat="server"></asp:TextBox> </td> <td class="style56"> <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server"
16
ControlToValidate="txtCardEx" ErrorMessage="MM/YY" ForeColor="Red" ValidationExpression="^((0[1-9])|(1[02]))\/(\d{2})$"></asp:RegularExpressionValidator> </td> <td class="style31"> </td> <td class="style27"> </td> <td class="style26"> </td> <td> </td> </tr> <tr> <td colspan="2"> Card holder name printed on card:</td> <td class="style46"> <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="txtCardHolderName" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style53"> <asp:TextBox ID="txtCardHolderName" runat="server"></asp:TextBox> </td> <td class="style55"> </td> <td class="style18"> </td> <td class="style48"> </td> <td class="style56"> </td> <td class="style31"> </td> <td class="style27"> </td> <td class="style26"> </td> <td> </td> </tr> <tr> <td colspan="2"> Credit Card Number:</td> <td class="style46"> <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="txtCCNumber" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> </td> <td class="style53"> <asp:TextBox ID="txtCCNumber" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="txtCCNumber" ErrorMessage="16d or Less 16d" ForeColor="Red" ValidationExpression="^[0-9]{1,16}$"></asp:RegularExpressionValidator> </td> <td class="style55"> Card Verification Code (3digit):</td> <td class="style44"> <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ControlToValidate="txtthreedigit" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
17
</td> <td class="style48"> <asp:TextBox ID="txtthreedigit" runat="server"></asp:TextBox> </td> <td class="style56"> <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ControlToValidate="txtthreedigit" ErrorMessage="3d" ForeColor="Red" ValidationExpression="\d{3}"></asp:RegularExpressionValidator> </td> <td class="style31"> </td> <td class="style27"> </td> <td class="style26"> </td> <td> </td> </tr> </table> <br /> <table class="style2"> <tr> <td class="style40"> </td> <td class="style39"> <asp:Button ID="ButtonConfirmPurchase" runat="server" style="font-weight: 700" Text="Confirm Purchase" ToolTip="Click To Confirm Purchase" onclick="ButtonConfirmPurchase_Click" /> </td> <td class="style41"> <asp:Button ID="ButtonCancel" runat="server" Height="26px" style="font-weight: 700" Text="Cancel" ToolTip="Click To Cancel" Width="157px" onclick="ButtonCancel_Click" CausesValidation="False" /> </td> <td> </td> </tr> <tr> <td class="style38" colspan="3"> <asp:Label ID="LabelR2" runat="server" ForeColor="#3333FF" style="font-weight: 700"></asp:Label> </td> <td> </td> </tr> <tr> <td class="style38" colspan="3"> <asp:Label ID="LabelR3" runat="server" ForeColor="Red" style="font-weight: 700"></asp:Label> </td> <td> </td> </tr> </table> </p> </asp:Content>
18