<script language="c#" runat="server">
void EncryptText(object sender, EventArgs e)
{
// Instantiate our object. main.rc4encrypt is the namespace
// name and the class name which gives us a reference to the
// class. We use rc4 as the variable name for our object and
// use the new keyword to create a new instance of the object
main.rc4encrypt rc4 = new main.rc4encrypt();
// Set the Password property to the password we want to use
rc4.Password = txtPassword.Text;
// Set the PlainText password of the text we want to encrypt
rc4.PlainText = txtEncrypt.Text;
// Write out to the page the encrypted output
lblResults.Text = "The Encrypted Text is:<br />" + rc4.EnDeCrypt();
// Create the hyperlink to decrypt the string
lnkDecrypt.Text="Decrypt the String";
lnkDecrypt.NavigateUrl = "/demos/rc4decrypt.aspx?enc=" +
Server.UrlEncode(rc4.EnDeCrypt());
}
</script>
<form runat="server">
Choose a Password:
<asp:textbox id="txtPassword" runat="server" />
<br />
Enter the Text to be Encrypted:
<asp:textbox id="txtEncrypt" runat="server" Columns="45" MaxLength="50" />
<br />
<asp:Button runat="server" OnClick="EncryptText" Text="Encrypt!" />
<p>
<asp:label id="lblResults" runat="server" /><br />
<asp:hyperlink id="lnkDecrypt" runat="server" />
</form>
|