The use of password protection, MD5 and SHA1 algorithms in ASP.NET

xiaoxiao2021-03-05  30

Your home page or you manage the website has a variety of passwords to be protected, put your password directly in a database or a lot of security hazards, so password encrypted storage is the most common practice. It is very easy to achieve encryption in ASP.NET. The CookieAuthentication class is available in the .NET SDK, where the HashPasswordforstoringInConfigFile method can use the MD5 and SHA1 algorithms directly.

The example is as follows:
File: Encrypting.aspx
<% @Page Language = "c #" codebehind = "encrypting.cs" autoeventwireup = "false" inherits = "encrypting.encrypting"%>







< / asp: textbox>

Encrypting Password (MD5):





file: encrypting.cs

namespace encrypting
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
Using System.drawing;
Using System.Web;
Using System.Web.SessionState;
Using System.Web.ui;
Using System.Web.ui.WebControls;
USING System.Web.ui.htmlControls;
Using system.web.security;
///


/// summary d Escription for encrypting.
///
public class encrypting: system.Web.ui.page
{
protected system.web.ui.webcontrols.label MD5;

转载请注明原文地址:https://www.9cbs.com/read-39373.html

New Post(0)