小编Tua*_*uan的帖子

ASP.net身份验证

我是CS专业,我刚刚完成了ASP.net网站的设计,对于网站我需要一个登录认证系统......我不想使用SQLMembershipProvider,因为我真的想学习如何自己创建一个......无论如何,这就是我想出来的,我想知道是否有人可以给我一些反馈,提示或建议.

提前致谢

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Security.Cryptography;

/// <summary>
/// Summary description for PwEncrypt
/// </summary>
public class PwEncrypt
{
    public const int DefaultSaltSize = 5;

    private static string CreateSalt()
    {
        RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
        byte[] buffer = new byte[DefaultSaltSize];
        rng.GetBytes(buffer);
        return Convert.ToBase64String(buffer);
    }

    public static string CreateHash(string password, out string salt)
    {
        salt = CreateSalt();
        string saltAndPassword = String.Concat(password, salt);
        string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPassword, "SHA1");
        hashedPassword = string.Concat(hashedPassword, salt);
        return hashedPassword; …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net salt

5
推荐指数
1
解决办法
379
查看次数

使用三元运算符缩短代码

如何使用三元运算符缩短以下内容?

if ((pos - maxPos) == (c.clientWidth)) {
    $j("#next").addClass("filter");
} else {
    $j("#next").removeClass("filter");
}
Run Code Online (Sandbox Code Playgroud)

javascript ternary-operator

0
推荐指数
1
解决办法
251
查看次数

标签 统计

.net ×1

asp.net ×1

c# ×1

javascript ×1

salt ×1

ternary-operator ×1