ASPX CODE
<%@ Page Title="" Language="C#" MasterPageFile="~/Common.master" AutoEventWireup="true" CodeFile="DecryptPassword.aspx.cs" Inherits="DecryptPassword" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:TextBox runat="server" ID="txtPassword" Width="200px"/>
<asp:Button runat="server" ID="btnGenerate" OnClick="btnGenerate_Click" Text="generate"/>
<br />
<asp:Label runat="server" ID="lblDecryptwithkey" Text="Decypt with Key" />
<asp:TextBox runat="server" ID="txtDecryptWithKey" Width="500px" Text="test" />
<asp:Button runat="server" ID="btnDecryptWithKey" OnClick="btnDecryptWithKey_Click" Text="Decrypt with key"/>
<br />
<asp:Label runat="server" ID="lblencryptwithkey" Text="Encrypt with Key" />
<asp:TextBox runat="server" ID="txtEncryptWithKey" Width="500px" Text="test" />
<asp:Button runat="server" ID="btnEncryptWithKey" OnClick="btnEncryptWithKey_Click" Text="Encrypt with key"/>
<br />
<asp:Label runat="server" ID="lblEncrypt" Text="Encrypt" />
<asp:TextBox runat="server" ID="txtEncrypt" Width="500px" Text="test" />
<asp:Button runat="server" ID="btnEncrypt" OnClick="btnEncrypt_Click" Text="Encrypt"/>
<br />
<asp:Label runat="server" ID="lblDecrypt" Text="Decrypt" />
<asp:TextBox runat="server" ID="txtDecrypt" Width="500px" Text="test" />
<asp:Button runat="server" ID="btnDecrypt" OnClick="btnDecrypt_Click1" Text="Decrypt"/>
<br />
<asp:Label runat="server" ID="lblDecode" Text="Decode" />
<asp:TextBox runat="server" ID="txtDecode" Width="500px" Text="test" />
<asp:Button runat="server" ID="btnDecode" OnClick="btnDecode_Click" Text="Decode"/>
<br />
<asp:Label runat="server" ID="lblEncode" Text="Encode" />
<asp:TextBox runat="server" ID="txtEncode" Width="500px" Text="test" />
<asp:Button runat="server" ID="btnEncode" OnClick="btnEncode_Click" Text="Encode"/>
<br />
<asp:Label runat="server" ID="lblMD5Encrypt" Text="MD5 Encrypt" />
<asp:TextBox runat="server" ID="txtMD5Encrypt" Width="500px" Text="test" />
<asp:Button runat="server" ID="btnMD5Encrypt" OnClick="btnMD5Encrypt_Click" Text="Encode"/>
<br />
<asp:Label runat="server" ID="lblMD5Decrypt" Text="MD5 Decrypt" />
<asp:TextBox runat="server" ID="txtMD5Decrypt" Width="500px" Text="test" />
<asp:Button runat="server" ID="btnMD5Decrypt" OnClick="btnMD5Decrypt_Click" Text="Decode"/>
</asp:Content>
ASPX.CS code
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class DecryptPassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnDecrypt_Click(object sender, EventArgs e)
{
//txtDecrypt.Text = LuminousSecurity.Encryption.Encrypt(txtPassword.Text);
//txtDecrypt.Text = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "md5");
//txtDecrypt.Text= LuminiousUtility.Util.Utility.DecodePassword(txtPassword.Text);
}
protected void btnDecryptWithKey_Click(object sender, EventArgs e)
{
txtDecryptWithKey.Text = LuminousSecurity.Encryption.DecryptString(txtPassword.Text.Trim(), "lumbibthabik");
}
protected void btnDecode_Click(object sender, EventArgs e)
{
txtDecode.Text = LuminiousUtility.Util.Utility.DecodePassword(txtPassword.Text);
}
protected void btnEncrypt_Click(object sender, EventArgs e)
{
txtEncrypt.Text = LuminousSecurity.Encryption.Encrypt(txtPassword.Text);
}
protected void btnDecrypt_Click1(object sender, EventArgs e)
{
txtDecrypt.Text = LuminousSecurity.Encryption.Decrypt(txtPassword.Text);
}
protected void btnGenerate_Click(object sender, EventArgs e)
{
}
protected void btnEncryptWithKey_Click(object sender, EventArgs e)
{
txtEncryptWithKey.Text = LuminousSecurity.Encryption.EncryptData(txtPassword.Text.Trim(), "lumbibthabik");
}
protected void btnEncode_Click(object sender, EventArgs e)
{
txtEncode.Text = LuminiousUtility.Util.Utility.EncodePassword(txtPassword.Text);
}
protected void btnMD5Encrypt_Click(object sender, EventArgs e)
{
txtMD5Encrypt.Text = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "MD5").ToString();
}
protected void btnMD5Decrypt_Click(object sender, EventArgs e)
{
var authCookie = txtPassword.Text;
HttpCookie cookie = new HttpCookie("pwd");
cookie.Values.Add("", txtPassword.Text);
if (authCookie == null) return;
var cookieValue = cookie.Value;
if (String.IsNullOrWhiteSpace(cookieValue)) return;
var ticket = FormsAuthentication.Decrypt("4e30e7e5cb14a6e482a3b01184251045");
txtMD5Decrypt.Text = ticket.ToString();
}
}
No comments:
Post a Comment