PASSWORD TEXTBOX
pessoal, uma duvida:
se eu fizer um programa com o seguinte codigo:
Private Sub Command1_Click()
If password = "senha" Then
If login = "usuario" Then
Form2.Show 'aqui começaria o programa
End If
End If
End Sub
seria bem facil um programa hacker descobrir a senha?
e se alguem souber uma forma maior de proteção, posta ai!
obrigado desde já!
se eu fizer um programa com o seguinte codigo:
Private Sub Command1_Click()
If password = "senha" Then
If login = "usuario" Then
Form2.Show 'aqui começaria o programa
End If
End If
End Sub
seria bem facil um programa hacker descobrir a senha?
e se alguem souber uma forma maior de proteção, posta ai!
obrigado desde já!
olha kra, você poderia até simplificar esse teu código:
Private Sub Command1_Click()
If password = "senha" and login = "usuario" Then
Form2.Show 'aqui começaria o programa
End If
End Sub
Private Sub Command1_Click()
If password = "senha" and login = "usuario" Then
Form2.Show 'aqui começaria o programa
End If
End Sub
Para dar uma dificultada(coisa que não é necessario, porque para um hacker descobrir o login e senha, teria muito trabalho, se conseguisse ainda), você poderia usar algum dos exemplos de criptorafia que tem em códigos fontes.
não seria possivel descobrir a senha a menos que consiga abrir o codigo fonte do seu executavel.
outra idéia seria vc gravar a senha CRIPTOGRAFADA no arquivo ini e DESCRIPTOGRAFAR na hora de comparar com a que o usuario digitou no login.
é a forma que eu costumo usar....
outra idéia seria vc gravar a senha CRIPTOGRAFADA no arquivo ini e DESCRIPTOGRAFAR na hora de comparar com a que o usuario digitou no login.
é a forma que eu costumo usar....
Na minha opinião, a seguir pelo exemplo do linux, acho melhor você CRIPTOGRAFAR a senha que o usuário digitar e comparar a com a senha no arquivo Ini, ou seja, as duas
ficam criptografadas. Dessa maneira você não corre o risco de "expor" a sua senha
descriptografando-a. Bom, é o que acho que funciona melhor.
ficam criptografadas. Dessa maneira você não corre o risco de "expor" a sua senha
descriptografando-a. Bom, é o que acho que funciona melhor.
Tarcis, basicamente, vc repetiu o que eu disse...... rs.....
Helloooooooo!!!!!!!!!!!!!!!!!!!!!
Alguém ai copiou o que eu disse??????
Alguém ai copiou o que eu disse??????
Para dar uma dificultada(coisa que não é necessario, porque para um hacker descobrir o login e senha, teria muito trabalho, se conseguisse ainda), você poderia usar algum dos exemplos de criptorafia que tem em códigos fontes.
Coloque isso em um módulo:
Option Explicit
Public Const CASE_SENSITIVE_PASSWORD = False
'Encrypta o texto
Public Function EncryptText(strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String
If Not CASE_SENSITIVE_PASSWORD Then
strPwd = UCase$(strPwd)
End If
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c + Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next i
Else
strBuff = strText
End If
EncryptText = strBuff
End Function
'Decrypta o texto encryptado anteriormente
Public Function DecryptText(strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String
If Not CASE_SENSITIVE_PASSWORD Then
strPwd = UCase$(strPwd)
End If
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c - Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next i
Else
strBuff = strText
End If
DecryptText = strBuff
End Function
e isso no form_load , com 2 textbox com o mesmo nome(text1):
Dim teste, subst
Private Sub Form_Load()
verify = App.Path & "\jukebox.cfg"
Open verify For Input As #1
While Not EOF(1)
For i = 0 To 2
Line Input #1, subst
If subst = "" Then
Else
Text1(i) = subst
Text1(i) = DecryptText(Text1(i), "max")
End If
Next i
Wend
Close #1
End Sub
E se quiser alterar a senha, pode alterar com esse código(coloque 2textbox com mesmo nome(text1), e uma textbox com o nome text2):
For i = 0 To 2
If Text2 = "" Then
Text2 = EncryptText(Text1(i), "max")
Else
Text2 = Text2 & vbCrLf & EncryptText(Text1(i), "max")
End If
Next i
Open App.Path & "\jukebox.cfg" For Output As #2 ' determina o arquivo
Replace Text2, " ", ""
Print #2, Text2.Text ' enviar o texto da text box
Close #2 ' Fecha o arquivo
Option Explicit
Public Const CASE_SENSITIVE_PASSWORD = False
'Encrypta o texto
Public Function EncryptText(strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String
If Not CASE_SENSITIVE_PASSWORD Then
strPwd = UCase$(strPwd)
End If
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c + Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next i
Else
strBuff = strText
End If
EncryptText = strBuff
End Function
'Decrypta o texto encryptado anteriormente
Public Function DecryptText(strText As String, ByVal strPwd As String)
Dim i As Integer, c As Integer
Dim strBuff As String
If Not CASE_SENSITIVE_PASSWORD Then
strPwd = UCase$(strPwd)
End If
If Len(strPwd) Then
For i = 1 To Len(strText)
c = Asc(Mid$(strText, i, 1))
c = c - Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next i
Else
strBuff = strText
End If
DecryptText = strBuff
End Function
e isso no form_load , com 2 textbox com o mesmo nome(text1):
Dim teste, subst
Private Sub Form_Load()
verify = App.Path & "\jukebox.cfg"
Open verify For Input As #1
While Not EOF(1)
For i = 0 To 2
Line Input #1, subst
If subst = "" Then
Else
Text1(i) = subst
Text1(i) = DecryptText(Text1(i), "max")
End If
Next i
Wend
Close #1
End Sub
E se quiser alterar a senha, pode alterar com esse código(coloque 2textbox com mesmo nome(text1), e uma textbox com o nome text2):
For i = 0 To 2
If Text2 = "" Then
Text2 = EncryptText(Text1(i), "max")
Else
Text2 = Text2 & vbCrLf & EncryptText(Text1(i), "max")
End If
Next i
Open App.Path & "\jukebox.cfg" For Output As #2 ' determina o arquivo
Replace Text2, " ", ""
Print #2, Text2.Text ' enviar o texto da text box
Close #2 ' Fecha o arquivo
Esqueci de comentar:
crie um arquivo com o nome jukebox.cfg na mesma pasta que o programa estiver salvo
Duvida esclarecida? Encerre o tópico e me Pontue^^
crie um arquivo com o nome jukebox.cfg na mesma pasta que o programa estiver salvo
Duvida esclarecida? Encerre o tópico e me Pontue^^

Tópico encerrado , respostas não são mais permitidas