CRIPTOGRAFAR SENHA COMO O PHPBB

FROSTYNHO 15/07/2011 02:29:56
#379215
alguem tem alguma função para criptografar senhas igual o phpbb, preciso fazer um sistema de login em cima do banco de dado de um forum phpbb.
RODRIGOFERRO 15/07/2011 08:09:25
#379224
Resposta escolhida
Ora não é o famoso [Ô]MD5[Ô] ??

Vide Macorati: VB .NET - Criando código mais seguro - MD5



Imports System.Security.Cryptography
Imports System.Text

Public Class Util

Public Shared Function GeraHashMD5(ByVal texto As String) As String

Dim btyScr() As Byte = ASCIIEncoding.ASCII.GetBytes(texto)
Dim objMd5 As New MD5CryptoServiceProvider()
Dim btyRes() As Byte = objMd5.ComputeHash(btyScr)
Dim intTotal As Integer = (CInt(btyRes.Length * 2) + CInt((btyRes.Length / 8)))
Dim strRes As StringBuilder = New StringBuilder(intTotal)
Dim intI As Integer

For intI = 0 To btyRes.Length - 1
strRes.Append(BitConverter.ToString(btyRes, intI, 1))
Next intI

Return strRes.ToString().TrimEnd(New Char() {[Ô] [Ô]c}).ToLower

End Function
End Class



Abraços
FROSTYNHO 15/07/2011 08:29:22
#379226
então zero, é MD5, mais quando eu encripto a senha para comparar com a senha do banco, da senha invalida, estou fazendo da seguinte forma:

    Private myCON As MySql.Data.MySqlClient.MySqlConnection
Private myCMD As MySql.Data.MySqlClient.MySqlCommand
Private myDRR As MySql.Data.MySqlClient.MySqlDataReader

Public Sub LoginMySQL(ByVal Username As TextBox, ByVal Password As TextBox)
[ô]MsgBox(GeraHashMD5(Password.Text))
myCMD = New MySql.Data.MySqlClient.MySqlCommand([Ô]SELECT * FROM phpbb_users WHERE username = [ô][Ô] & Username.Text & [Ô][ô][Ô], myCON)
myDRR = myCMD.ExecuteReader()
If myDRR.HasRows = False Then
MsgBox([Ô]Usuário inválido.[Ô])
Username.Clear()
Username.Select()
Else
myDRR.Close()
myCMD.Dispose()
myCMD = New MySql.Data.MySqlClient.MySqlCommand([Ô]SELECT * FROM phpbb_users WHERE username = [ô][Ô] & Username.Text & [Ô][ô] AND user_password = [ô][Ô] & GeraHashMD5(Password.Text) & [Ô][ô][Ô], myCON)
myDRR = myCMD.ExecuteReader()
If myDRR.HasRows = False Then
MsgBox([Ô]Senha inválida.[Ô])
Password.Clear()
Password.Select()
Else
myDRR.Read()

MsgBox([Ô]Logado como: [Ô] & myDRR.Item([Ô]username[Ô]))

End If
End If
myDRR.Close()
myCMD.Dispose()
End Sub
FROSTYNHO 15/07/2011 09:03:43
#379229
descobri uma coisa, se eu pego o phpbb assim que acabo de criar, meu usuario, o ADMIN, se eu faço esse esquema que eu citei acima da certo, porem se eu altero minha senha pelo forum, ja num funciona mais, pq será?
FROSTYNHO 15/07/2011 10:29:39
#379244
descobri aki agora, ele usa a função Crypt do php, alguem sabe me dizer se tem como cryptografar do mesmo modo no vb.net?
RODRIGOFERRO 15/07/2011 11:48:11
#379258


Imports System.Text
Imports System.Security.Cryptography
Imports System.IO
Imports MySql.Data
Imports MySql.Data.MySqlClient

Public Class Form1

Dim conn As MySqlConnection
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Dim myData As MySqlDataReader
Dim md5pass As String


Public Shared Function MD5Encrypt(ByVal str As String) As String
Dim md5 As MD5CryptoServiceProvider
Dim bytValue() As Byte
Dim bytHash() As Byte
Dim strOutput As String
Dim i As Integer
md5 = New MD5CryptoServiceProvider
bytValue = System.Text.Encoding.UTF8.GetBytes(str)
bytHash = md5.ComputeHash(bytValue)
md5.Clear()
For i = 0 To bytHash.Length - 1
strOutput &= bytHash(i).ToString([Ô]x[Ô]).PadLeft(2, [Ô]0[Ô])
Next
MD5Encrypt = strOutput
End Function

Private Sub NButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NButton1.Click

userbox.Enabled = False
passbox.Enabled = False
md5pass = MD5Encrypt(passbox.Text)
conn = New MySqlConnection()
conn.ConnectionString = [Ô]server=XXXXX;[Ô] _
& [Ô]user id=XXXXX;[Ô] _
& [Ô]password=XXXXX;[Ô] _
& [Ô]database=XXXXX;[Ô]

conn.Open()

Dim sqlquery = [Ô]SELECT * FROM phpbb_users WHERE username_clean = [ô][Ô] + userbox.Text + [Ô][ô] AND user_password = [ô][Ô] + md5pass + [Ô][ô][Ô]
myCommand.Connection = conn
myCommand.CommandText = sqlquery

myAdapter.SelectCommand = myCommand

myData = myCommand.ExecuteReader()

If myData.HasRows = 0 Then
userbox.Enabled = True
passbox.Enabled = True
conn.Close()
conn.Open()
Else
conn.Close()
MsgBox([Ô]Success![Ô], MsgBoxStyle.Information, [Ô]KEWL![Ô])
End If
End Sub
End Class



Axei isso vagando por ai... testa ai...
FROSTYNHO 15/07/2011 11:55:54
#379263
tem msn zero? me add ai: krazybeat@hotmail.com, vou lhe mostrar o problema
Tópico encerrado , respostas não são mais permitidas