如何将加密值与纯文本进行比较? [英] How to compare encrypted value with plain text?

查看:82
本文介绍了如何将加密值与纯文本进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将存储在数据库中的加密值与用户输入的值[纯文本]进行比较,但我找不到合适的技术来执行此操作。



当文本被解密时,该值仍然不是纯文本,它包含符号和字母。



我正在使用此链接中的这些AES技术;

C#AES 256位盐加密库 [ ^ ]



我想要的是以某种方式将数据库中找到的加密值与用户的输入进行比较,以查看两个值是否匹配。



谢谢!

解决方案

直接比较它们的唯一方法是使用以下方法加密用户输入相同的密钥并进行比较,或解密DB值并进行比较。



但是......我只是在猜测你是在尝试处理密码?如果是这样,那么你真的,真的不想加密任何东西!您应该散列原始内容,然后存储散列 - 然后在登录时进行验证,对散列的内容进行散列,并比较两个散列。这里有一个提示:密码存储:如何操作。 [ ^

I'm trying to compare an encrypted value stored in a database with a value [plain text] that is inputted by the user but I cannot find the appropriate technique to do so.

When the text is being decrypted, the value is still not plain text, it contains symbols and letters.

I'm using these AES techniques found in this link;
C# AES 256 bits Encryption Library with Salt[^]

All I want is to somehow compare the encrypted value found in the database with the input from the user to see if both values match.

Thanks !

解决方案

The only way to directly compare them is to either encrypt the user input using the same key and compare that, or decrypt the DB value and compare that.

But...I'm just guessing here that you are trying to handle passwords? If so, then you really, really don't want to encrypt anything! You should Hash the original, and store the hash instead - then for validation when they log in, you hash what they typed, and compare the two hashes. There is a tip showing how here: Password Storage: How to do it.[^]


这篇关于如何将加密值与纯文本进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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