ASP. NET AJAX implements MD5 encryption

Source: Internet
Author: User
Tags md5 encryption

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 ">
&LT;TITLE&GT;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>
&LT;H3&GT;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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.