Some Encrypting code I am using.
Public Function EncryptKey(ByVal strKey As String)
Dim ch As Char
Dim intCh As Integer
Dim tmp As String = Nothing
Dim i As Integer
For i = 0 To Len(strKey) - 1
intCh = Asc(strKey.Chars(i))
If (intCh < 245) Then
intCh = intCh + 10
Else
intCh = 255 - intCh
End If
ch = Chr(intCh)
tmp = tmp & ch
Next
Return tmp
End Function
Public StoredKey As String
Dim key As Long
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\myprogram", "key", EncryptKey(Trim(key)))
StoredKey = Trim(key)
Public StoredKey As String
Public Function DecryptPassword(ByVal strKey As String)
Dim ch As Char
Dim intCh As Integer
Dim tmp As String = Nothing
Dim i As Integer
For i = 0 To Len(strKey) - 1
intCh = Asc(strKey.Chars(i))
If (intCh > 10) Then
intCh = intCh - 10
Else
intCh = 255 - intCh
End If
ch = Chr(intCh)
tmp = tmp & ch
Next
Return tmp
End Function
Dim key As Long
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
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..
Updated to show more code.
This post has been edited by NY Andrew: 16 August 2011 - 05:10 PM

New Topic/Question
Reply



MultiQuote








|