RegPass
This code allows you to enter and read an encrypted password from your VB project by inserting and reading the encrypted password to and from the registry.
AI
AIサマリー: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
ソースコード
Private Sub Form_Load()
Text1.Text = ""
End Sub
Private Sub Command1_Click()
Label1.Caption = ""
If Command1.Caption = "Set Password" Then
Command1.Caption = "Check Password"
Call SetPassword
Else
ThisPass = Text1.Text
Call CheckPassword
End If
End Sub
Public Sub SetPassword()
Dim CheckPass, ThisNewPass, PassTempVar As String
'Check and See if the password has been set
CheckPass = QueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\RegPass", "Pass")
If CheckPass = "" Then
'If Not Create a new registry Entry
Ret = CreateNewKey(HKEY_LOCAL_MACHINE, "Software\RegPass")
End If
'Encrypt the String with a static Seed (You can Change this so long as you use the same seed in CheckPassword)
ThisNewPass = CryptIt(Text1.Text, "ThisSeed")
'Now Set the Password (Encrypted in the Registry)
Ret = SetKeyValue(HKEY_LOCAL_MACHINE, "SOFTWARE\RegPass", "Pass", ThisNewPass, REG_SZ)
Text1.Text = ""
Label1.Caption = "Password Set"
End Sub
Public Sub CheckPassword()
' I could have used 1 variable for this but I think this is less confusing
Dim CheckPass As String
Dim ThisLength As Integer
'Retrieve the Encypted Password from the Regoistry
CheckPass = CryptIt(QueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\RegPass", "Pass"), "ThisSeed")
'For some strange reason I have to trim a trailing character...????
ThisLength = Len(CheckPass) - 1
CheckPass = Left(CheckPass, ThisLength)
'Check It Against the Entered Password
If (CheckPass = Text1.Text) Then
Command1.Caption = "Set Password"
Label1.Caption = ("Password Check Was Successful")
Else
Label1.Caption = ("Incorrect Password...Try Again (was really '" + CheckPass + "')")
Text1.Text = ""
End If
End Sub
Private Sub Command2_Click()
End
End Sub
オリジナルのコメント (3)
Wayback Machineから復元