帮助在窗体启动时解密和检查RegistryKey值 [英] Help Decrypting and checking RegistryKey value on form startup

查看:98
本文介绍了帮助在窗体启动时解密和检查RegistryKey值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,所以我花了一整天,却一无所获.我已经加密了用户输入的值,并将其成功存储在Windows注册表中.现在,我在启动窗体时需要解密该RegistryKey,并确保它与最初存储的密钥相同.我的解密代码一直在工作,但是如果我进入注册表并在该键值上添加一个额外的字符,则我的程序仍在运行..如果该RegistryKey不是最初由用户输入的那个,则不应运行. .

即使在表格加载下,我也尝试过:

Alright so I have spent an entire day and am getting nowhere. I have encrypted a user inputted value and successfully stored it in the Windows Registry. Now I am having problems Decrypting that RegistryKey when my Form starts up and making sure it is the same key that was originally stored. My decrypting code has been working but if I go inside the Registry and add an extra character on to that keys value, my program is still running.. It is not supposed to run if that RegistryKey is not the one that was originally user inputted..

Under the Forms Load even I have tried:

If (My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\myprogram", "key", Nothing) Is Nothing) Then
            My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\myprogram", "key", "")
            StoredKey = ""
        Else
            StoredKey = DecryptPassword(CStr(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\myprogram", "key", Nothing)))
        End If

        If (StrComp(key, StoredKey) = 0) Then
            MsgBox("Registry key NOT added, already exists.")
        Else
            RegisterForm.Show()
        End If



我还尝试了许多其他示例,但我也不想将它们全部发布.因此,无论如何,我可以检查是否存在RegistryKey并将其解密以确保程序启动时未对其进行更改吗?

谢谢你的帮助.经过一整天的工作后,这是我的最后希望,然后才是整个概念..



And I also have tried A LOT of other examples, but I am not going too post them all. So is there anyway I can check if a RegistryKey exists and Decrypt it to make sure that it has not been changed on my programs startup?

Thanks for your help. After a full day of nothing working out this is my last hope, before I just throw in the towel on this entire concept..

推荐答案

注册表未加密.您存储的数据以某种方式被加密或散列.您尚未告诉您使用过的方法来加密"此数据,因此无法告诉您使用什么来解密"该数据.

至于是否存在不存在的值,请查看 [
The registry is not encrypted. The data you stored was encrypted or hashed somehow. You haven''t told use what you used to "encrypt" this data so it''s impossible to tell you what you use to "decrypt" it.

As for if a value exists of not, take a look at this[^] overload of the GetValue method. If the value doesn''t exist, you provide a default value that the method will return if the value does not exist, preferrably something that is something your app would normally store in that value.


我已经成功地独自解决了这个问题.我花了整整一天的时间进行调整,最终得到了可行的组合.
I have successfully solved this issue on my own. I spent the entire day switching things around and eventually ended up with a combination that works.


这篇关于帮助在窗体启动时解密和检查RegistryKey值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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