1. [Image] ASP. NET AJAX effect. png
2. [Code] front-end code Html/javascript/jquery
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<TITLE>MD5 encryption using ASP. NET jquery ajax-Collayi </title>
<script type= "Text/javascript" src= "Http://keleyi.com/keleyi/pmedia/jquery/jquery-1.10.2.min.js" ></ Script>
<!--connect your network--
<body>
<div>
<H3>MD5 Encryption Please enter a string to encrypt: <input type= "text" id= "input_keleyi_com"/>
<br/>
<span id= "Md5type" >
<input id= "Md5type_1" type= "Radio" name= "md5type_keleyi_com" value= "1" checked= "checked"/><label for= " Md5type_1 ">32 bit [Big]</label>
<input id= "md5type_2" type= "Radio" name= "md5type_keleyi_com" value= "2"/><label for= "md5type_2" >32 bit [small] </label>
<input id= "Md5type_3" type= "Radio" name= "md5type_keleyi_com" value= "3"/><label for= "md5type_3" >16 bit [large] </label>
<input id= "Md5type_4" type= "Radio" name= "md5type_keleyi_com" value= "4"/><label for= "md5type_4" >16 bit [small] </label>
</span><input type= "button" value= "Encrypt" onclick= "Javascript:md5ajax ();"/>
<br/>
Result: <input id= "md5result_keleyi_com" type= "text"/>
</div>
<script type= "Text/javascript" >
function Md5ajax () {
var k_input = $ ("#input_ke" + "leyi_com"). Val ();
var K_format = $ (' input[name= ' md5type_keleyi_com "]:checked '). Val ();
$.ajax ({
Type: "Post",
URL: "Keleyimd5.aspx/getmd5",
Data: "{' Input ': '" + k_input + "', ' format ': '" + K_format + "'}",
ContentType: "Application/json; Charset=utf-8 ",
DataType: "JSON",
Success:function (data) {
if (String) (DATA.D)! = "-1") {
$ ("#MD5Result_k" + "eleyi_com"). Val (DATA.D);
}
Else
Alert (' encryption failed ');
},
Error:function (Err) {
Alert (' Collayi reminds you: ' ERROR ' + err ');
}
});
}
</script>
</body>
3. [Code][html]aspx page
<%@ page language= "C #" autoeventwireup= "true" codebehind= "KeleyiMd5.aspx.cs" inherits= " Keleyi.Com.KeleyiAjax.KeleyiMd5 "%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>asp.net jquery Ajax example of MD5 encryption-Ke keeper </title>
<body>
<div>
</div>
</body>
4. [Code]aspx.cs background C # code
Using System;
Using System.Web.Services;
Namespace Keleyi.Com.KeleyiAjax
{? http://www.enterdesk.com/special/shouhui/?
public partial class KeleyiMd5:System.Web.UI.Page
{hand-painted pictures
protected void Page_Load (object sender, EventArgs e)
{
}
<summary>
///
</summary>
<param name= "Input" ></param>
<param name= "Format" >1 represents 32-bit uppercase, 2 for 32-bit lowercase, 3 for 16-bit capitalization, 4 for 16-bit lowercase </param>
<returns></returns>
[WebMethod]
public static string GetMd5 (string input, int format)
{
Switch (format)
{
Case 1:
return Getmd5upper32 (input);
Case 2:
return Getmd5upper32 (Input). ToLower ();
Case 3:
return Getmd5upper32 (Input). Substring (8, 16);
Case 4:
return Getmd5upper32 (Input). Substring (8, 16). ToLower ();
Default
return Getmd5upper32 (input);
}
}
static string Getmd5upper32 (String input)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (Input, "MD5");
}
}
}
ASP. NET AJAX implements MD5 encryption