Asp.net成员资格-如何明确匹配安全性答案? [英] Asp.net Membership-How to match security answer explicitly?

查看:55
本文介绍了Asp.net成员资格-如何明确匹配安全性答案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要匹配用户输入的安全答案和存储在aspnet_Membership表中的安全答案. 我不想使用resetpassword("Securityanswer")方法来验证用户.

I need to match security answer entered by user and security answer stored in aspnet_Membership table. I dont want to use resetpassword("Securityanswer") method to verify user.

有什么方法可以加密输入的安全答案或解密存储的安全答案.

Is there any way to encrypt entered security answer or to decrypt stored security answer.

谢谢.

推荐答案

/将输入的秒转换为字节数组/

            Dim bytes As Byte() = Encoding.Unicode.GetBytes(secAns)

/这非常重要,可以将您的密钥转换为64位字符串以获取原始的急用密码./

            Dim src As Byte() = Convert.FromBase64String(key) 

            /*Concatenate sec ans and hash key*/

            Dim dst As Byte() = New Byte(src.Length + (bytes.Length - 1)) {}

            Buffer.BlockCopy(src, 0, dst, 0, src.Length)
            Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length)

            /*Create algo object for SHA1*/

            Dim algorithm As HashAlgorithm = HashAlgorithm.Create("SHA1")

            /*Compute hash value of concatenated ans and key*/

            Dim inArray As Byte() = algorithm.ComputeHash(dst)

            /*Convert hashed ans back to string*/

            Dim hashedAns As String = Convert.ToBase64String(inArray)

这篇关于Asp.net成员资格-如何明确匹配安全性答案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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