如何生成的ASP.NET MVC的加密哈希? [英] How do I generate an encryption hash in ASP.NET MVC?

查看:113
本文介绍了如何生成的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);

或<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.hashpasswordforstoringinconfigfile%28v=VS.71%29.aspx\">FormsAuthentication.HashPasswordForStoringInConfigFile方法

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

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