⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hash.aspx

📁 asp.net技术内幕的书配源码
💻 ASPX
字号:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Security.Cryptography" %>

<script language="C#" runat=server>
byte[] Convert2ByteArray(string strInput) 
{
	int intCounter;
	char[] arrChar;
	
	arrChar = strInput.ToCharArray();
	byte[] arrByte = new byte[arrChar.Length];
	
	for (intCounter=0; intCounter <= arrByte.Length-1; intCounter++)
		arrByte[intCounter] = Convert.ToByte(arrChar[intCounter]);
		
	return arrByte;
}

void Button_Click( Object sender , EventArgs e ) {
	byte[] arrHashInput;
	byte[] arrHashOutput;
	MD5CryptoServiceProvider objMD5;

	objMD5 = new MD5CryptoServiceProvider();
	arrHashInput = Convert2ByteArray( txtInput.Text );
	arrHashOutput = objMD5.ComputeHash( arrHashInput );
	lblOutput.Text = BitConverter.ToString( arrHashOutput );
}

</Script>

<html>
<head><title>Hash.aspx</title></head>
<body>

<form Runat="Server">

<h2>Generate MD5 Hash</h2>

<b>Enter text to hash:</b>
<br>
<asp:TextBox
  id="txtInput"
  TextMode="Multiline"
  Columns="50"
  Rows="10"
  Runat="Server" />
<p>
<asp:Button
  Text="Compute Hash!"
  OnClick="Button_Click"
  Runat="Server" />
<p>
<b>Hash value:</b>
<br>
<asp:Label
  ID="lblOutput"
  Runat="Server" />

</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -