how to change these windows form code to web form code?

hi, 

i'm a beginner of c#,i want to know how to change these windows form code to web form code

////////////
private void buttonSign_Click(
object sender, System.EventArgs e)
{
//get original message as byte array
byte[] messagebytes = Encoding.UTF8.GetBytes(
textOriginalMessage.Text);
//create digest of original message using SHA1
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] hashbytes =
sha1.ComputeHash(messagebytes);
//display hash bytes in hex format
StringBuilder sb = new StringBuilder();
for (int i=0; i<hashbytes.Length; i++)
{
sb.Append(String.Format(
"{0,2:X2} ", hashbytes[i]));
}
textMessageDigestSHA1.Text = sb.ToString();
//create DSA object using default key
DSACryptoServiceProvider dsa =
new DSACryptoServiceProvider();
//sign hash using OID for SHA-1
signaturebytes =
dsa.SignHash(hashbytes, "1.3.14.3.2.26");
//provide DSA parameters to verification
dsaparams = dsa.ExportParameters(false);
buttonVerify.Text=dsaparams.ToString();
//display digital signature in hex format
sb = new StringBuilder();
for (int i=0; i<signaturebytes.Length; i++)
{
sb.Append(String.Format(
"{0,2:X2} ", signaturebytes[i]));
}
textSignature.Text = sb.ToString();
//display DSA parameter details in hex format
sb = new StringBuilder();
for (int i=0; i<dsaparams.P.Length; i++)
{
sb.Append(String.Format(
"{0,2:X2} ", dsaparams.P[i]));
}
textBoxP.Text = sb.ToString();
sb = new StringBuilder();
for (int i=0; i<dsaparams.Q.Length; i++)
{
sb.Append(String.Format(
"{0,2:X2} ", dsaparams.Q[i]));
}
textBoxQ.Text = sb.ToString();
for (int i=0; i<dsaparams.Y.Length; i++)
{
sb.Append(String.Format(
"{0,2:X2} ", dsaparams.Y[i]));
}
textBoxY.Text = sb.ToString();
for (int i=0; i<dsaparams.G.Length; i++)
{
sb.Append(String.Format(
"{0,2:X2} ", dsaparams.G[i]));
}
textBoxG.Text = sb.ToString();
//do UI stuff
buttonSign.Enabled = false;
buttonVerify.Enabled = true;
buttonVerify.Select();
}
private void buttonVerify_Click(
object sender, System.EventArgs e)
{
//get possibly modified message as byte array
byte[] messagebytes = Encoding.UTF8.GetBytes(
textOriginalMessage.Text);
//create digest of original message using SHA1
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] hashbytes =
sha1.ComputeHash(messagebytes);
//create DSA object using parameters from signing
DSACryptoServiceProvider dsa =
new DSACryptoServiceProvider();
dsa.ImportParameters(dsaparams);
//do verification on hash using OID for SHA-1
bool match = dsa.VerifyHash(
hashbytes, "1.3.14.3.2.26", signaturebytes);
//show message box with result of verification
String strResult;
if (match)
strResult = "VerifySignature returned TRUE";
else
strResult = "VerifySignature returned FALSE";
MessageBox.Show(
strResult,
"Result From Calling VerifySignature",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
//do UI stuff
buttonSign.Enabled = true;
buttonVerify.Enabled = false;
buttonVerify.Select();
}
//variables communicated from signing to verifying
DSAParameters dsaparams;
byte[] signaturebytes;
0
m_tre65
5/19/2004 10:57:03 AM
📁 asp.net.web-forms
📃 93655 articles.
⭐ 6 followers.

💬 3 Replies
👁️‍🗨️ 2248 Views

are you getting errors? because the listed code (I skimmed so I might have missed something) doesn't have any winform specific calls.. exception is the MessageBox.. but you can replace that with just a simple label and change the text of that.. or a slew of other methods..
ah! pooh!
0
pooh_drummer
5/19/2004 4:11:59 PM
Can u rewrite this code for me with web form c# asp.net?
0
m_tre65
5/20/2004 8:39:39 AM
sorry.. this is a help forum.. not do your homework/work forum..
ah! pooh!
0
pooh_drummer
5/20/2004 3:27:13 PM
Reply: