如何在ASP.NET MVC中生成加密散列? [英] How do I generate an encryption hash in ASP.NET MVC?

查看:108
本文介绍了如何在ASP.NET MVC中生成加密散列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究创建一个自定义成员登录系统(用于学习),并且我无法找出C#命令来生成加密散列。

I am looking into creating a custom members login system (for learning) and I haven't been able to figure out the C# command to generate an encrypted hash.

我需要导入某个命名空间吗?

Is there a certain namespace I need to import or anything like that?

推荐答案

使用命名空间System.Security.Cryptography:

Using the namespace System.Security.Cryptography:

MD5 md5 = new MD5CryptoServiceProvider();
Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
Byte[]  encodedBytes = md5.ComputeHash(originalBytes);

return BitConverter.ToString(encodedBytes);

FormsAuthentication.HashPasswordForStoringInConfigFile方法

这篇关于如何在ASP.NET MVC中生成加密散列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆