当我将其保存到注册表时,最简单的加密密码是什么? [英] What is the easiest way to encrypt a password when I save it to the registry?

查看:160
本文介绍了当我将其保存到注册表时,最简单的加密密码是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在以明文形式写下这个oops!,这是一个内部程序,所以这不是很糟糕,但我想做的是正确的。在写入注册表时我应该如何加密?如何解密?

Currently I'm writing it in clear text oops!, it's an in house program so it's not that bad but I'd like to do it right. How should I go about encrypting this when writing to the registry and how do I decrypt it?

OurKey.SetValue("Password", textBoxPassword.Text);


推荐答案

您不解密验证密码!



使用SHA256提供程序使用SHA256提供程序,当您必须挑战时,使用用户哈希的输入,并查看两个散列是否匹配。

You don't decrypt authentication passwords!

Hash them using something like the SHA256 provider and when you have to challenge, hash the input from the user and see if the two hashes match.

byte[] data = System.Text.Encoding.ASCII.GetBytes(inputString);
data = new System.Security.Cryptography.SHA256Managed().ComputeHash(data);
String hash = System.Text.Encoding.ASCII.GetString(data);

保留密码可逆是一个真正的可怕的模型。

Leaving passwords reversible is a really horrible model.

编辑2:我以为我们只是在谈论前端身份验证。当然,有些情况下,您需要为需要可逆的其他事物加密密码,但应该有一个单向锁定(除了极少数例外)。

I thought we were just talking about front-line authentication. Sure there are cases where you want to encrypt passwords for other things that need to be reversible but there should be a 1-way lock on top of it all (with a very few exceptions).

我已经升级了散列算法,但为了尽可能的强度,您希望保留一个私人盐,并将其添加到您的在散列之前输入 。当你比较时,你会再次这样做。这增加了另一层,使得人们更难以扭转。

I've upgraded the hashing algorithm but for the best possible strength you want to keep a private salt and add that to your input before hashing it. You would do this again when you compare. This adds another layer making it even harder for somebody to reverse.

这篇关于当我将其保存到注册表时,最简单的加密密码是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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